SqlCommand Question - Programatically Set Value?

  • Thread starter Thread starter Rangy
  • Start date Start date
R

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!
 
Rangy said:
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.
 
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);
 
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);


Thank you!!!!!
 
Back
Top