try
{
string SQLstr = "Select * from Employee";
SqlConnection con = new SqlConnection("Connection_String");
//Open Connection
con.Open();
SqlCommand com = new SqlCommand(SQLstr, con);
SqlDataReader read = com.ExecuteReader();
DataTable dt = new DataTable();
dt.Load(read);
// finally bind the data to the grid
dataGridView1.DataSource = dt;
// Close Connection
con.Close();
}
catch (Exception ex)
{
MessageBox.Show("Error");
}
Monday, February 7, 2011
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment