用Updata方法更新数据库出错
SqlConnection thisConnection = new SqlConnection("Data Source=PC-200903081647;Initial Catalog=movie;Integrated Security=True");SqlDataAdapter thisAdapter=new SqlDataAdapter ("select 片名,时长 from 影片",thisConnection);
SqlCommandBuilder thisBuilder=new SqlCommandBuilder (thisAdapter );
DataSet thisDataSet = new DataSet();
thisAdapter.Fill(thisDataSet ,"影片");
Console .WriteLine ("name before change:{0}",thisDataSet .Tables ["影片"].Rows[7]["片名"]);
thisDataSet .Tables ["影片"].Rows[7]["片名"]="功夫之王";
thisAdapter .Update (thisDataSet ,"影片"); Console .WriteLine ("name after change:{0}",thisDataSet .Tables ["影片"].Rows[7]["片名"]);
错误提示:
对于不返回任何键列信息的SelectCommand,不支持UpdateCommand的动态SQL生成 --------------------编程问答-------------------- 设置个主键看看,我也试过,设置后就好了 --------------------编程问答-------------------- select 的时候把主键也选上
补充:.NET技术 , C#