DataSet 里面存放呢多个表的数据....如何更新到数据库
我使用 ,
pDb.fillBuilder( "SELECT * FROM PubProgram ");
pDb.thisAdapter.Fill(theDataSet, "PubProgram ");
pDb.fillBuilder( "SELECT * FROM webPost ");
pDb.thisAdapter.Fill(theDataSet, "webPost ");
pDb.fillBuilder( "SELECT * FROM Site ");
pDb.thisAdapter.Fill(theDataSet, "Site ");
把多个表的数据放在呢 theDataSet 里面呢....询问一下.我这样的存放多表数据到DataSet 中的方法对吗?
可是我在用下面的语句更新其中其一个数据表的时候却提示我找不到 其他表中的列
pDb.thisAdapter.Update(theDataSet, "PubProgram ");
注解:
上面的 pDb.fillBuilder() 是我自己的一个方法.
thisAdapter = new OleDbDataAdapter(query, thisConnection);
thisBuilder = new OleDbCommandBuilder(thisAdapter);
------解决方案--------------------这个问题我也不懂,帮你顶一下
------解决方案--------------------public DataSet CreateCmdsAndUpdate(DataSet myDataSet,string myConnection,string mySelectQuery,string myTableName)
{
OleDbConnection myConn = new OleDbConnection(myConnection);
OleDbDataAdapter myDataAdapter = new OleDbDataAdapter();
myDataAdapter.SelectCommand = new OleDbCommand(mySelectQuery, myConn);
OleDbCommandBuilder custCB = new OleDbCommandBuilder(myDataAdapter);
myConn.Open();
DataSet custDS = new DataSet();
myDataAdapter.Fill(custDS);
//code to modify data in dataset here
myDataAdapter.Update(custDS, myTableName);
myConn.Close();
return custDS;
}