datagridview更新数据库(SqlDataAdapter.update()的用法
发布网友
发布时间:2022-04-07 19:36
我来回答
共1个回答
热心网友
时间:2022-04-07 21:05
SqlConnection conn = new SqlConnection("SERVER=.;UID=sa;PWD=sa;DATABASE=pubs");
SqlDataAdapter adapter = new SqlDataAdapter("SELECT * FROM sales",conn);
SqlCommandBuilder cmdbuilder = new SqlCommandBuilder(adapter);
DataSet ds=new DataSet();
adapter.Fill(ds);
adapter.UpdateCommand = cmdbuilder.GetUpdateCommand();
adapter.Update(ds,ds.Table[0].TableName);