i need your help in ado.net
-
i need your help ,i want to make selection of table to be dynamic corresponds to selected item from combobox more description //to be like that SqlCommand cmd = new SqlCommand("select * from '" + comboBox1.SelectedItem.ToString() +"'", con); //not SqlCommand cmd = new SqlCommand("select * from table1 ", con); and thanks
-
i need your help ,i want to make selection of table to be dynamic corresponds to selected item from combobox more description //to be like that SqlCommand cmd = new SqlCommand("select * from '" + comboBox1.SelectedItem.ToString() +"'", con); //not SqlCommand cmd = new SqlCommand("select * from table1 ", con); and thanks
And your problem is?
The difficult we do right away... ...the impossible takes slightly longer.
-
And your problem is?
The difficult we do right away... ...the impossible takes slightly longer.
i have more than one table and all of them have the same attributes i want to choose the table i want to get info from table i choose from combobox i want your help because this doesn't work SqlCommand cmd = new SqlCommand("select * from '" + comboBox1.SelectedItem.ToString() +"'", con); when i choose table from combobox like school this error showed : incorrect syntax near 'school'.
-
i have more than one table and all of them have the same attributes i want to choose the table i want to get info from table i choose from combobox i want your help because this doesn't work SqlCommand cmd = new SqlCommand("select * from '" + comboBox1.SelectedItem.ToString() +"'", con); when i choose table from combobox like school this error showed : incorrect syntax near 'school'.
But you have not made clear what your question is.
The difficult we do right away... ...the impossible takes slightly longer.
-
i have more than one table and all of them have the same attributes i want to choose the table i want to get info from table i choose from combobox i want your help because this doesn't work SqlCommand cmd = new SqlCommand("select * from '" + comboBox1.SelectedItem.ToString() +"'", con); when i choose table from combobox like school this error showed : incorrect syntax near 'school'.
Take out the single quotes from your query string. make it
SqlCommand cmd = new SqlCommand("select * from " + comboBox1.SelectedItem.ToString(), con);
The difficult we do right away... ...the impossible takes slightly longer.
-
But you have not made clear what your question is.
The difficult we do right away... ...the impossible takes slightly longer.
in my combobox i have places like: school hospital club each one is table in my database i want when i choose hospital it returns all hospitals i put in this table & its atributes and when i choose club it returns all clubs i put in this table & its atributes sorry for my bad english
-
Take out the single quotes from your query string. make it
SqlCommand cmd = new SqlCommand("select * from " + comboBox1.SelectedItem.ToString(), con);
The difficult we do right away... ...the impossible takes slightly longer.
-
Take out the single quotes from your query string. make it
SqlCommand cmd = new SqlCommand("select * from " + comboBox1.SelectedItem.ToString(), con);
The difficult we do right away... ...the impossible takes slightly longer.
5!:thumbsup:
-
IMO if you had written the failing SQL statement to the console (or to a log file) you would easily have seen where it went wrong yourself. :) PS: if your combobox allows editing, your SQL statement is open for injection attacks, and people could easily delete your tables...
Luc Pattyn [My Articles] Nil Volentibus Arduum