Binding SqlCE to Datagrid

  • Thread starter Thread starter Nathan Zumwalt
  • Start date Start date
You don't really bind a connection to a grid. You bind a table to a grid.
Something like:

String query = String.Format( "SELECT * FROM {0};", UpdateSelectEdit.Text );

SqlCommand cmd = new SqlCommand( query,

sqlconnect );

dataset = new DataSet();

dataadapter = new SqlDataAdapter();

dataadapter.SelectCommand = cmd;

dataadapter.Fill(dataset);

ResultGrid.DataSource = dataset.Tables[ 0 ];

In this case, UpdateSelectEdit is a TextEdit where the table name is entered
by the user. Sqlconnect is the SQL connection object.



Paul T.
 
Also ensure that you have set Reference to System.Data.Common under project
references.

Best Regards,
Y. Sivaram
 
This was my problem.... I didn't have a reference to the
System.Data.Common namespace.

Thanks!

-Nathan
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top