操作数据库问题!初级问题,请指教
从数据库中找到符合条件的记录,进行更新!
为何老报错 "对于不返回任何键列信息的 SelectCommand 不支持 UpdateCommand 的动态 SQL 生成。 "?
如何修改呢,我刚学ASP.net,请多多照顾
string m_sql= "select * from item where id=2277 ";
SqlConnection sqlConnection1=new SqlConnection(strConn);
SqlDataAdapter sqlDataAdapter1=new SqlDataAdapter(m_sql,sqlConnection1);;
DataSet dataset=new DataSet();
SqlCommandBuilder sqlcommandbuilder=new SqlCommandBuilder(sqlDataAdapter1);
sqlConnection1.Open();
sqlDataAdapter1.Fill(dataset, "ly ");
sqlConnection1.Close();
if (dataset.Tables[0].Rows[0][ "item_serial "].ToString()== "048 ")
{
Label1.Text= "Yes ";
dataset.Tables[0].Rows[0][ "item_serial "]= "hello "
sqlDataAdapter1.Update(dataset, "ly ");
}
else
{
Label1.Text= "NO ";
}
[解决办法]
item 表设置主键没?