数据绑定:
[CODE]SqlConnection con = new SqlConnection("server=.;database=file;uid=sa;pwd=1");
try
{
SqlCommand com = new SqlCommand("select * from aa ", con);
da = new SqlDataAdapter(com);
da.SelectCommand = com;
SqlCommandBuilder cb = new SqlCommandBuilder(da);
ds = new DataSet();
da.Fill(ds);
dataGridView1.DataSource = ds.Tables[0];
}
catch (Exception ex)
{
MessageBox.Show(ex.ToString());
}
finally
{
con.Close();
}[/CODE]
更新:
[CODE] da.Update(ds.Tables[0].GetChanges());
ds.Tables[0].AcceptChanges();[/CODE]