Home All Groups Group Topic Archive Search About

SqlCommand Question - Programatically Set Value?

Author
15 Feb 2007 2:48 AM
Rangy
Say you have the following in your code.

SqlCommand objCommand = new SqlCommand("StoredProcedure1",
objConnection);

Is there a way to replace the "StoredProcedure1" value at runtime
based on a selection in a list or textbox entry.

Thanks!

Author
15 Feb 2007 6:54 AM
RobinS
"Rangy" <davidw***@gmail.com> wrote in message
news:1171507708.679994.35090@k78g2000cwa.googlegroups.com...
> Say you have the following in your code.
>
> SqlCommand objCommand = new SqlCommand("StoredProcedure1",
> objConnection);
>
> Is there a way to replace the "StoredProcedure1" value at runtime
> based on a selection in a list or textbox entry.
>
> Thanks!
>

Won't this work?

SqlCommand objCommand = new sqlCommand(myListBox.SelectedItem.ToString,
objConnection);

Robin S.
Author
15 Feb 2007 11:55 AM
Darren Sim
The "storedProcedure1" part is simply a string, therefore any string value
can be entered here.
i.e.;

string myString = textbox1.text;

//Then replace "StoredProcedure1" with mystring.

SqlCommand objCommand = new SqlCommand(myString,
objConnection);

Show quote
"Rangy" <davidw***@gmail.com> wrote in message
news:1171507708.679994.35090@k78g2000cwa.googlegroups.com...
> Say you have the following in your code.
>
> SqlCommand objCommand = new SqlCommand("StoredProcedure1",
> objConnection);
>
> Is there a way to replace the "StoredProcedure1" value at runtime
> based on a selection in a list or textbox entry.
>
> Thanks!
>
Author
16 Feb 2007 1:51 AM
Rangy
Show quote
On Feb 15, 6:55 am, "Darren Sim" <darr***@sirius.co.uk> wrote:
> The "storedProcedure1" part is simply a string, therefore any string value
> can be entered here.
> i.e.;
>
> string myString = textbox1.text;
>
> //Then replace "StoredProcedure1" with mystring.
>
> SqlCommand objCommand = new SqlCommand(myString,
> objConnection);
>
> "Rangy" <davidw***@gmail.com> wrote in message
>
> news:1171507708.679994.35090@k78g2000cwa.googlegroups.com...
>
> > Say you have the following in your code.
>
> > SqlCommand objCommand = new SqlCommand("StoredProcedure1",
> > objConnection);
>
> > Is there a way to replace the "StoredProcedure1" value at runtime
> > based on a selection in a list or textbox entry.
>
> > Thanks!


Thank you!!!!!

AddThis Social Bookmark Button