PC Review


Reply
Thread Tools Rate Thread

Managing a SQLParameter/ODBCParameter Object

 
 
Pierluigi Terzoli
Guest
Posts: n/a
 
      10th Sep 2004
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.


 
Reply With Quote
 
 
 
 
Joyjit Mukherjee
Guest
Posts: n/a
 
      10th Sep 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" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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.
>
>



 
Reply With Quote
 
Pierluigi Terzoli
Guest
Posts: n/a
 
      10th Sep 2004
You're right, Thanks Joyjit for helping me.
Bye, Pierluigi.

"Joyjit Mukherjee" <(E-Mail Removed)> ha scritto nel messaggio
news:%(E-Mail Removed)...
> 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" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
> > 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.
> >
> >

>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Passing type Object to SqlParameter.Value =?Utf-8?B?Y2FzaGRlc2ttYWM=?= Microsoft ADO .NET 4 4th Oct 2007 09:22 PM
Dynamically Populating a SqlParameter object =?Utf-8?B?am1obWFpbmU=?= Microsoft ADO .NET 5 28th Jun 2005 06:59 PM
new OdbcParameter(" Christopher Weaver Microsoft C# .NET 2 25th May 2005 12:10 AM
Problem with SQLParameter data type (because 'System.Data.SqlClient.SqlParameter' is not derived from 'StoreBO.StoreBackOffice.SqlParameter'. ) Stacey Levine Microsoft VB .NET 3 16th Mar 2005 03:39 AM
Trouble Removing SqlParameter objects from Command object Elliot M. Rodriguez Microsoft VB .NET 0 16th Sep 2003 08:10 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 08:23 AM.