就是想批量处理吧,你的数据库表要有主键
private void datagridsave()
{
if (ds.HasChanges())
{
try
{
SqlDataAdapter adapter = new SqlDataAdapter("select * from Customer", new SqlConnection(SqlHelper.ConnectionString));
SqlCommandBuilder cmdBuilder = new SqlCommandBuilder(adapter);
adapter.DeleteCommand = new SqlCommand("", new SqlConnection(SqlHelper.ConnectionString));
adapter.InsertCommand = new SqlCommand("", new SqlConnection(SqlHelper.ConnectionString));
adapter.UpdateCommand = new SqlCommand("", new SqlConnection(SqlHelper.ConnectionString));
adapter.SelectCommand = new SqlCommand("select * from Customer", new SqlConnection(SqlHelper.ConnectionString));