Hi everybody,
I have a simple question:
I need to execute the same SQL statement (an Insert one) several times.
This command has some parameters, I'll make an example:
INSERT INTO test (id) VALUES (@id) --> (for SQLServer engine)
So, I'd like to have a SqlParameter collection and every time change the
value of the parameter only.
I didn't find any method to do it.
Do I have to SqlParameter.Clear() the collection and rebuild it every time
??
Thanks in advance, Pierluigi.

Re: Managing a SQLParameter/ODBCParameter Object by Joyjit

Joyjit
Fri Sep 10 04:07:05 CDT 2004

Hi,

as your parameter collection changes for each execution, you need to change
the values only viz.,

SqlParameter myParameter = new SqlParameter("@MyVar", SqlDbType.VarChar);
myParameter["@MyVar"].Value = "My Value";

// later on

myParameter["@MyVar"].Value = "My 2nd Value";

etc.

Regards

Joyjit

"Pierluigi Terzoli" <pierluigi_terzoli@hotmail.com> wrote in message
news:OvbkTMxlEHA.3760@TK2MSFTNGP12.phx.gbl...
> Hi everybody,
> I have a simple question:
> I need to execute the same SQL statement (an Insert one) several times.
> This command has some parameters, I'll make an example:
> INSERT INTO test (id) VALUES (@id) --> (for SQLServer engine)
> So, I'd like to have a SqlParameter collection and every time change the
> value of the parameter only.
> I didn't find any method to do it.
> Do I have to SqlParameter.Clear() the collection and rebuild it every time
> ??
> Thanks in advance, Pierluigi.
>
>



Re: Managing a SQLParameter/ODBCParameter Object by Pierluigi

Pierluigi
Fri Sep 10 04:23:21 CDT 2004

You're right, Thanks Joyjit for helping me.
Bye, Pierluigi.

"Joyjit Mukherjee" <joyjit_mukherjee@hotmail.com> ha scritto nel messaggio
news:%2334iNWxlEHA.3476@tk2msftngp13.phx.gbl...
> Hi,
>
> as your parameter collection changes for each execution, you need to
change
> the values only viz.,
>
> SqlParameter myParameter = new SqlParameter("@MyVar", SqlDbType.VarChar);
> myParameter["@MyVar"].Value = "My Value";
>
> // later on
>
> myParameter["@MyVar"].Value = "My 2nd Value";
>
> etc.
>
> Regards
>
> Joyjit
>
> "Pierluigi Terzoli" <pierluigi_terzoli@hotmail.com> wrote in message
> news:OvbkTMxlEHA.3760@TK2MSFTNGP12.phx.gbl...
> > Hi everybody,
> > I have a simple question:
> > I need to execute the same SQL statement (an Insert one) several times.
> > This command has some parameters, I'll make an example:
> > INSERT INTO test (id) VALUES (@id) --> (for SQLServer engine)
> > So, I'd like to have a SqlParameter collection and every time change the
> > value of the parameter only.
> > I didn't find any method to do it.
> > Do I have to SqlParameter.Clear() the collection and rebuild it every
time
> > ??
> > Thanks in advance, Pierluigi.
> >
> >
>
>