datagridview数据更新的问题
为什么下面的UPDATA更新不了???
SqlConnection conn = sqlClass.sqlcon();
SqlDataAdapter da = new SqlDataAdapter(sqlcmd, conn);
da.Fill(dataSet);
SqlCommandBuilder cb = new SqlCommandBuilder(da);
da.Update(dataSet);
------解决方案-------------------- //数据库数据更新(传DataSet和DataTable的对象)
public DataSet UpdateDataBase(DataSet changedDataSet,string tableName)
{
this.myConnection = new SqlConnection(connectionString);
this.da = new SqlDataAdapter(this.strSQL,this.myConnection);
this.sqlCmdBld = new SqlCommandBuilder(da);
this.da.Update(changedDataSet,tableName);
return changedDataSet;//返回更新了的数据库表
}
没错啊
------解决方案--------------------update()中跟上表名 看看 如:
SqlConnection conn = sqlClass.sqlcon();
SqlDataAdapter da = new SqlDataAdapter(sqlcmd, conn);
dataset ds=new dataset();
SqlCommandBuilder cb = new SqlCommandBuilder(da);
da.Fill(ds,"表名");
da.Update(ds,"表名");