sql query in the SqlDataAdapter()

Posted by syedsaleemss on Stack Overflow See other posts from Stack Overflow or by syedsaleemss
Published on 2010-04-14T11:29:05Z Indexed on 2010/04/14 11:33 UTC
Read the original article Hit count: 265

Filed under:

Im using c# .net windows form application. I have loaded names of all the tables present in a database into a combobox.

Now i need to display the contents of the selected table name.

Normally we use

SqlDataAdapter adp= new SqlDataAdapter("Select * from employee", con);

This works fine. but instead of explicitly giving table name i.e employee i need to set it to combobox1.selected item.

I have given like this its not working: string filename= combobox1.selecteditem; SqlDataAdapter adp= new SqlDataAdapter("Select * from filename", con);

How can I select filename dynamically?

© Stack Overflow or respective owner

Related posts about c#