问题描述
System.Data.OleDb.OleDbException:操作必须使用一个可更新的查询。atSystem.Data.OleDb.OleDbCommand.ExecuteCommandTextErrorHandling(Int32hr)atSystem.Data.OleDb.OleDbCommand.ExecuteCommandTextForSingleResult(tagDBPARAMSdbParams,Object&executeResult)atSystem.Data.OleDb.OleDbCommand.ExecuteCommandText(Object&executeResult)atSystem.Data.OleDb.OleDbCommand.ExecuteCommand(CommandBehaviorbehavior,Object&executeResult)atSystem.Data.OleDb.OleDbCommand.ExecuteReaderInternal(CommandBehaviorbehavior,Stringmethod)atSystem.Data.OleDb.OleDbCommand.ExecuteNonQuery()atxinyun.aspx.mustread.parentmessage.parentmessage.ImageButton1_Click(Objectsender,ImageClickEventArgse)inC:xinyunaspxmustreadparentmessageparentmessage.aspx.cs:line135
解决方案
解决方案二:
把代码帖出来大哥..
解决方案三:
这是代码:usingSystem;usingSystem.Collections;usingSystem.ComponentModel;usingSystem.Data;usingSystem.Drawing;usingSystem.Web;usingSystem.Web.SessionState;usingSystem.Web.UI;usingSystem.Web.UI.WebControls;usingSystem.Web.UI.HtmlControls;usingSystem.Text;usingSystem.Data.OleDb;usingSystem.Configuration;usingxinyun.classes.bases;namespacexinyun.aspx.mustread.parentmessage{///<summary>///parentmessage的摘要说明。///</summary>publicclassparentmessage:System.Web.UI.Page{protectedSystem.Web.UI.WebControls.RequiredFieldValidatorRequiredFieldValidator1;protectedSystem.Web.UI.WebControls.TextBoxzuti;protectedSystem.Web.UI.WebControls.RequiredFieldValidatorRequiredFieldValidator2;protectedSystem.Web.UI.WebControls.TextBoxname;protectedSystem.Web.UI.WebControls.TextBoxlianxidizhi;protectedSystem.Web.UI.WebControls.TextBoxdianhua;protectedSystem.Web.UI.WebControls.TextBoxmail;protectedSystem.Web.UI.WebControls.RegularExpressionValidatorRegularExpressionValidator1;protectedSystem.Web.UI.WebControls.RequiredFieldValidatorRequiredFieldValidator3;protectedSystem.Web.UI.WebControls.TextBoxcontent;protectedSystem.Web.UI.WebControls.ImageButtonImageButton1;protectedSystem.Web.UI.WebControls.ImageButtonImageButton2;publicstringAddtime;protectedSystem.Web.UI.WebControls.RequiredFieldValidatorRequiredFieldValidator4;privateOleDbConnectioncn=newOleDbConnection();privatevoidPage_Load(objectsender,System.EventArgse){//在此处放置用户代码以初始化页面}#regionWeb窗体设计器生成的代码overrideprotectedvoidOnInit(EventArgse){////CODEGEN:该调用是ASP.NETWeb窗体设计器所必需的。//InitializeComponent();base.OnInit(e);}///<summary>///设计器支持所需的方法-不要使用代码编辑器修改///此方法的内容。///</summary>privatevoidInitializeComponent(){this.ImageButton1.Click+=newSystem.Web.UI.ImageClickEventHandler(this.ImageButton1_Click);this.ImageButton2.Click+=newSystem.Web.UI.ImageClickEventHandler(this.ImageButton2_Click);this.Load+=newSystem.EventHandler(this.Page_Load);}#endregionprivatevoidImageButton1_Click(objectsender,System.Web.UI.ImageClickEventArgse){if(this.IsValid){//stp=newst();//if(this.chkIsHidden.Checked)//{//p.IsHidden=true;//}//else//{//p.IsHidden=false;//}Addtime=System.DateTime.Now.ToString();//Addtime=System.DateTime.Now.ToLongTimeString();//intface=Convert.ToInt32(Request.Form["face"].ToString());cn.ConnectionString="Provider=Microsoft.Jet.OLEDB.4.0;DataSource="+Server.MapPath("../../../db/xinyun.mdb");//取得数据库路径//stringdbPath=System.Configuration.ConfigurationSettings.AppSettings["../../../db/xinyun.mdb"];//定义数据库连接字符串//stringACconnStr="Provider=Microsoft.Jet.OleDb.4.0;DataSource="+Server.MapPath(dbPath);//创建数据库连接对像//OleDbConnectionACconn=newOleDbConnection(ACconnStr);try{//打开数据库//ACconn.Open();cn.Open();////intSSID=Convert.ToInt32(SID.SelectedValue);////判断添加新闻是否已存在//stringACsqlII="select*fromlybwherezuti!='"+this.zuti.Text+"'";////stringACsqlII="select*fromlyb";//OleDbCommandACcommII=newOleDbCommand(ACsqlII,ACconn);//OleDbDataReaderACdrII=ACcommII.ExecuteReader();////stringy="";//if(ACdrII.Read())//{//////if(this.zuti.Text==ACdrII["zuti"].ToString())//{////Response.Write("<script>alert('此信息已添加过');</script>");////Response.Write("<script>history.go(-2);</script>");//Response.Redirect("Error/404b.htm");//}//}////else////{//////this.TextBox1.Text=y;//ACdrII.Close();//if(Convert.ToInt32(SID.SelectedValue)==0)//{//stringACsqlI="insertintolyb(zuti,name,lianxidizhi,dianhua,qq,mail,www,face,content,Addtime,isys)values('"+this.zuti.Text+"','"+this.name.Text+"','"+this.lianxidizhi.Text+"','"+this.dianhua.Text+"','"+this.qq.Text+"','"+this.mail.Text+"','"+this.www.Text+"',"+face+",'"+this.content.Text.ToString().Replace("rn","<br>")+"','"+Addtime+"',"+Convert.ToBoolean(p.IsHidden)+")";stringACsqlI="insertintolyb(zuti,name,lianxidizhi,dianhua,mail,content,Addtime)values('"+this.zuti.Text+"','"+this.name.Text+"','"+this.lianxidizhi.Text+"','"+this.dianhua.Text+"','"+this.mail.Text+"','"+this.content.Text.ToString().Replace("rn","<br>")+"','"+Addtime+"')";OleDbCommandACcommI=newOleDbCommand(ACsqlI,cn);ACcommI.ExecuteNonQuery();Response.Write("<script>alert('留言成功添加');</script>");//}//else//{//stringACsqlI="insertintoArticle(ClassID,ChannelID,Title,LinkUrl,Content,Intro,Author,MY_Email,CopyFrom,MY_Site,Inputer,MY_QQ,UpdateTime)values('"+SID.SelectedValue+"','"+ChannelID.SelectedValue+"','"+Title.Text+"','"+LinkUrl.Text+"','"+Content.Text+"','"+Intro.Text+"','"+Author.Text+"','"+MY_Email.Text+"','"+CopyFrom.Text+"','"+MY_Site.Text+"','"+Inputer.Text+"','"+MY_QQ.Text+"','"+Addtime+"')";////OleDbCommandACcommI=newOleDbCommand(ACsqlI,ACconn);//ACcommI.ExecuteNonQuery();//Response.Write("<script>alert('信息成功添加');</script>");////}}catch(Exceptionex){Response.Write(ex.ToString());}finally{cn.Close();}}}privatevoidImageButton2_Click(objectsender,System.Web.UI.ImageClickEventArgse){this.zuti.Text="";this.name.Text="";this.lianxidizhi.Text="";this.dianhua.Text="";//this.qq.Text="";this.mail.Text="";//this.www.Text="";this.content.Text="";}}}
解决方案四:
跟踪一下"ACsqlI"看看是不是正确的sql语句.
解决方案五:
把你的sql语句response.write出来看看就知道是什么会事了吧?
解决方案六:
已经解决了