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

Recommended Answers

All 3 Replies

//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");
}

thank you very much AngelicOne i really neede it.

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

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.