0

how do I populate a datagrid in a smart device with data from a sql database(not SQL CE)

2
Contributors
3
Replies
4
Views
7 Years
Discussion Span
Last Post by AngelicOne
0
//to populate dataset
SqlDataAdapter da = new SqlDataAdapter ("select * from yourtable",connection);
DataSet ds = new DataSet();
//fill dataset with the returned results by da
da.Fill(ds);

//if dataset is not empty to prevent exception when there is no records returned
if(ds.Tables[0].Rows.Count > 0)
{
//populate the datagridview by dataset
dataGridView1.DataSource = ds.Tables[0]
}
else
{
//do something like
MessageBox.Show("no records");
}
0

if this works please mark this thread as solved so others that has the same problems will have an easy time finding the answer.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.