数据更新时出错
SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings[ "ConnectionString "].ConnectionString);
conn.Open() ;
SqlDataAdapter adapter = new SqlDataAdapter( "SELECT * FROM T_order ", conn);
SqlCommandBuilder builder = new SqlCommandBuilder(adapter);
DataSet thisDataSet = new DataSet();
adapter.Fill(thisDataSet, "t_order ");
thisDataSet.Tables[ "t_order "].Rows[1][1] = "22 ";
adapter.Update(thisDataSet, "t_order ");
conn.Close();
adapter.Update(thisDataSet, "t_order ");这一句时出错
------解决方案--------------------update sql?哪里去了?
------解决方案--------------------你要实现什么??
是把从表里查出来的数据,填充到数据集,再显示出来??
------解决方案--------------------如果要更新表里的数据,用sql
e.g
update 表名 set 字段名=值 where 主键=
------解决方案--------------------SqlDataAdapter adapter = new SqlDataAdapter( "SELECT * FROM T_order ", conn);
SqlCommandBuilder builder = new SqlCommandBuilder(adapter);
这两行代码后面少一行代码,builder.GetUpdateCommand ()
------解决方案--------------------LS正解
------解决方案--------------------T_order表中还没信息???
------解决方案--------------------主中没有主键吧