我有一张叫做的桌子provider.我有三个列person,place,thing.可能存在重复的人,重复的地方和重复的事物,但是永远不会存在重复的人物 - 事物 - 组合.
我如何使用这三列在ALTER TABLE中为MySQL中的此表添加复合主键?
此代码段引发错误:
更新无法在adapter.Update(ds)上找到TableMapping ['Table']或DataTable'Table'.); 线
为什么会抛出这种错误?
SqlConnection con = new SqlConnection();
con.ConnectionString = connectionString();
DataSet ds = new DataSet();
string strQuery = "SELECT * FROM Cars";
SqlDataAdapter adapter = new SqlDataAdapter();
adapter.SelectCommand = new SqlCommand(strQuery, con);
SqlCommandBuilder builder = new SqlCommandBuilder(adapter);
adapter.Fill(ds, "Cars");
//Code to modify data in the DataSet
ds.Tables["Cars"].Rows[0]["Brand"] = "NewBrand";
adapter.UpdateCommand = builder.GetUpdateCommand();
adapter.Update(ds);
Run Code Online (Sandbox Code Playgroud)