是C#的SqlServer连接,没对应的标签只能选择差不多的了。 public int UpdateByDataSet(DataSet ds, string strTableName) { try { SqlConnection sqlConn = new SqlConnection(strConn); SqlDataAdapter adapter = new SqlDataAdapter(); string strsql = "select * from " + strTableName; SqlCommand myCommand = new SqlCommand(strsql, sqlConn); adapter.SelectCommand = myCommand; SqlCommandBuilder myBuilder = new SqlCommandBuilder(adapter); myBuilder.RefreshSchema(); //必须用这个来刷新 adapter.Update(ds, strTableName); ds.AcceptChanges(); //必须有这个来让ds接受更改 return 0; } catch (Exception ex) { MessageBox.Show(ex.ToString()); return -1; } }
目前暂无任何回答
- 0 回答
- 0 关注
- 6100 浏览
添加回答
举报
0/150
提交
取消