Re: Parameters.Add by jeff
jeff
Sat Nov 13 15:36:09 CST 2004
If it's global, the last parameters used will always be there. You need to
clear them before reusing the object.
Jeff
"vb" <vb@discussions.microsoft.com> wrote in message
news:0CD198C3-FB41-48CC-81B1-D9FEBDBF3635@microsoft.com...
> Thanks for the response,
>
> What I am doing is that having a global Parameters object and use the same
> object for every Database call. Do I have to clear the parameters all the
> time or is there a better way.
>
> Thanks
> Vb
>
>
>
> "W.G. Ryan eMVP" wrote:
>
> > The Parameters collection is exactly that, a collection. If the item is
> > already in there, you just need to set the value.
> >
> > if(cmd.Parameters.Count > 0){
> > cmd.Parameters[0].Value = //Whatever
> >
> > }
> > else{
> > cmd.Parameters.Add["Wahtever", SqlDbType.int];
> > cmd.Parameters["Whatever"].Value = //Whatever
> > }
> >
> > --
> > W.G. Ryan MVP (Windows Embedded)
> >
> > TiBA Solutions
> > www.tibasolutions.com | www.devbuzz.com | www.knowdotnet.com
> > "vb" <vb@discussions.microsoft.com> wrote in message
> > news:69857B66-CAF9-4497-B7EA-50BDA8E9F9B6@microsoft.com...
> > > I am new to .Net. I have a windows form in which I am using a Stored
> > > Procedure to get the data. I am successful in retrieving the data,
however
> > > after closing the form and reopening the form I landed in a problem .
The
> > > error is too many parameters.What I did was I included a line
> > >
> > > SqlCmd.Parameters.Clear before Parameters.Add - line and I fixed the
> > issue.
> > > Can any explain why this is happening and how I can control it?
> > >
> > > thanks
> > > Vb
> >
> >
> >