方法有很多,现举其中的一种(常用)
首先取得数据,放到DataGrid里System.Data.SqlClient.SqlConnection conn = new System.Data.SqlClient.SqlConnection("server=localhost;database=northWind;uid=sa;password=194910");
conn.Open();
System.Data.SqlClient.SqlDataAdapter da = new System.Data.SqlClient.SqlDataAdapter("select * from customers",conn);
    dt = new System.Data.DataSet();
da.Fill(dt,"customers");然后绑定数据集和DataGrid
DataGrid.SetDataBinding(dt,"customers");
然后进行数据的操作如:
增加:
this.BindingContext[dt,"customers"].AddNew();
删除:
this.BindingContext[dt,"customers"].RemoveAt(this.BindingContext[dt,"customers"].Position);
最后把结果写回数据库:
SqlDataAdapter.Update(dt,"customers");