异常错误-操作必须使用可更新的查询. [英] Exception error - Operation must use an updateable query.

查看:77
本文介绍了异常错误-操作必须使用可更新的查询.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

为什么出现此异常错误.

我的CS代码在下面给出

Why this Exception error is giving.

My CS code is given below

void sub(Object s, EventArgs e)
{
   con.Open();
   com=con.CreateCommand();
   com.CommandText="UPDATE cv SET name = '" + t1.Text.Trim() + "',pass='" + t3.Text.Trim() + "',pdob='" + t5.Text.Trim() + "',mob='" + t6.Text.Trim() + "',psex='" + d1.SelectedItem.Text.Trim() + "',pstatus='" + d2.SelectedItem.Text.Trim() + "',address='" + tax.Value + "',cobj='" + t7.Text.Trim() + "',eque='" + t8.Text.Trim() + "',etype='" + d1.SelectedItem.Text.Trim() + "',eyear='" + t9.Text.Trim() + "',edur='" + t10.Text.Trim() + "',sind='" + d1.SelectedItem.Text.Trim() + "',sjob='" + t11.Text.Trim() + "',scom='" + t12.Text.Trim() + "',sdate='" + t13.Text.Trim() + "',sdur='" + t14.Text.Trim() + "' where email='" + t2.Text.Trim() + "'";
   try{
      com.ExecuteNonQuery();
      System.Web.UI.WebControls.Label lbl1=new System.Web.UI.WebControls.Label();
      lbl1.ForeColor=System.Drawing.Color.Yellow;
      lbl1.BackColor=System.Drawing.Color.Blue;
      lbl1.Text="Your record UPDATED sucessfully";
      ph1.Controls.Add(lbl1);
   }
   catch(Exception ex)
   {
      Response.Write(ex.Message);
   }
      con.Close();
   }

推荐答案

选中此

解决操作必须在访问中使用可更新的查询错误 [^ ]
Check this

Solve Operation Must Use an Updateable Query Error in Access[^]


第一个经验法则,永远不要将值连接到SQL语句.而是使用SqlParameter http://msdn.microsoft.com/en-us/library /system.data.sqlclient.sqlparameter.aspx [解决操作必须使用可更新的查询错误
[ ^ ]或 http://support.microsoft.com/kb/175168 [ ^ ]
The first rule of thumb, never concatenate values to an SQL statement. Instead use SqlParameterhttp://msdn.microsoft.com/en-us/library/system.data.sqlclient.sqlparameter.aspx[^] (if this is SQL Server, otherwise use relevant parameter class like OleDbParameter).

To your question, see: Solving the Operation Must Use An Updateable Query error
[^] or http://support.microsoft.com/kb/175168[^]


这篇关于异常错误-操作必须使用可更新的查询.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆