|
dev
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
SqlCommand Question - Programatically Set Value?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! "Rangy" <davidw***@gmail.com> wrote in message Won't this work?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! > SqlCommand objCommand = new sqlCommand(myListBox.SelectedItem.ToString, objConnection); Robin S. 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! >
Show quote
On Feb 15, 6:55 am, "Darren Sim" <darr***@sirius.co.uk> wrote: Thank you!!!!!> 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! |
|||||||||||||||||||||||