C# 从数据集更新数据库?
我想从我的数据集中更新我的数据库C# 从数据集更新数据库?,c#,sql-server,dataset,dataadapter,C#,Sql Server,Dataset,Dataadapter,我想从我的数据集中更新我的数据库 mydataadapter = new MySqlDataAdapter("SELECT * FROM table0; SELECT * FROM table1; SELECT * FROM table2;", con); myda.Fill(dataset); //...... // for example I'm doing a change like this ds.Tables[2].Rows[1][3] = "S"; //Then updating
mydataadapter = new MySqlDataAdapter("SELECT * FROM table0; SELECT * FROM table1; SELECT * FROM table2;", con);
myda.Fill(dataset);
//......
// for example I'm doing a change like this
ds.Tables[2].Rows[1][3] = "S";
//Then updating the database
MySqlCommandBuilder com = new MySqlCommandBuilder(mydataadapter);
mydataadapter.Update(dataset, "table2");
然后返回这个错误
TableMapping['table2'] or DataTable 'table2' didn't find by Update.
您有什么建议吗?数据适配器不知道表2,只有第三个记录集(加载到
ds.Tables[2]
)
要做到这一点,你需要一个团队
编辑:您有一个UpdateCommand,对吗?数据适配器不知道表2,只有第三个记录集(加载到
ds.Tables[2]
)
要做到这一点,你需要一个团队
编辑:您有一个UpdateCommand,对吗?我做了,没有返回错误。但数据库并没有改变。我可以添加executenonquery等:SMySqlCommandBuilder com=新的MySqlCommandBuilder(mydataadapter);不是吗?我做了,没有错误返回。但数据库并没有改变。我可以添加executenonquery等:SMySqlCommandBuilder com=新的MySqlCommandBuilder(mydataadapter);不是吗?