這段代碼被拋出出錯:的DataAdapter:更新找不到TableMapping [「表」]或數據表「表」
Update unable to find TableMapping['Table'] or DataTable 'Table'.) on adapter.Update(ds); line
爲什麼它拋出這種類型的錯誤?
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);
謝謝添Schmelter。 –
@ArifAnsari:不客氣。但考慮[接受](http://meta.stackexchange.com/questions/5234/how-does-accepting-an-answer-work)答案;) –