相关疑难解决方法(0)

ALTER TABLE添加复合主键

我有一张叫做的桌子provider.我有三个列person,place,thing.可能存在重复的人,重复的地方和重复的事物,但是永远不会存在重复的人物 - 事物 - 组合.

我如何使用这三列在ALTER TABLE中为MySQL中的此表添加复合主键?

mysql sql alter-table primary-key composite-primary-key

186
推荐指数
3
解决办法
32万
查看次数

DataAdapter:更新无法找到TableMapping ['Table']或DataTable'Table'

此代码段引发错误:

更新无法在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)

c# sql-server ado.net dataadapter

5
推荐指数
1
解决办法
7168
查看次数