如何将DataTable表存入数据库呢?
DataTable表是查询之后得到的,做了修改,想存入数据库。数据库中没有这个表。
[解决办法]
没有这个表,你从哪查出来的?
[解决办法]
必须得有表才行,就算是sql语句创建一个表。。。
[解决办法]
用DataAdatper.Update就可以把更新后的datatable保存懂啊数据库,
[解决办法]
protected void Reset_Click(object sender, EventArgs e){ ListDictionary keyValues = new ListDictionary(); ListDictionary newValues = new ListDictionary(); ListDictionary oldValues = new ListDictionary(); keyValues.Add("ProductID", int.Parse(((Label)DetailsView1.FindControl("IDLabel")).Text)); oldValues.Add("ProductName", ((Label)DetailsView1.FindControl("NameLabel")).Text); oldValues.Add("ProductCategory", ((Label)DetailsView1.FindControl("CategoryLabel")).Text); oldValues.Add("Color", ((Label)DetailsView1.FindControl("ColorLabel")).Text); newValues.Add("ProductName", "New Product"); newValues.Add("ProductCategory", "General"); newValues.Add("Color", "Not assigned"); LinqDataSource1.Update(keyValues, newValues, oldValues); DetailsView1.DataBind();}