“Insert into 语句的语法错误”的解决方法

在调用oleDbDataAdapter.Update(dataSet)时,出现这种错误

解决方法:

           oleDbCommandBuilder = new OleDbCommandBuilder(oleDbDataAdapter);

           oleDbCommandBuilder.QuotePrefix = "[";
           oleDbCommandBuilder.QuoteSuffix = "]";

update语句语法错误/insert into语句语法错误 怎么搞??

08-05

adoquery1.SQL.Clear;rnadoquery1.sql.add('update admin set pwd=password,department=un,purview=:pur,operater=:op,date=:lastdate where name=:username');rnadoquery1.Parameters.Clear;rnadoquery1.Parameters.AddParameter;rnadoquery1.Parameters[0].Name:='password';rnadoquery1.Parameters[0].DataType:=ftstring;rnadoquery1.Parameters[0].Direction:=pdinput;rnadoquery1.Parameters[0].Value:=edit2.Text;rnadoquery1.Parameters.AddParameter;rnadoquery1.Parameters[1].Name:='un';rnadoquery1.Parameters[1].DataType:=ftstring;rnadoquery1.Parameters[1].Direction:=pdinput;rnadoquery1.Parameters[1].Value:=edit3.Text;rnadoquery1.Parameters.AddParameter;rnadoquery1.Parameters[2].Name:='pur';rnadoquery1.Parameters[2].DataType:=ftstring;rnadoquery1.Parameters[2].Direction:=pdinput;rnadoquery1.Parameters[2].Value:=edit5.Text;rnadoquery1.Parameters.AddParameter;rnadoquery1.Parameters[3].Name:='op';rnadoquery1.Parameters[3].DataType:=ftstring;rnadoquery1.Parameters[3].Direction:=pdinput;rnadoquery1.Parameters[3].Value:=edit4.Text;rnadoquery1.Parameters.AddParameter;rnadoquery1.Parameters[4].Name:='lastdate';rnadoquery1.Parameters[4].DataType:=ftdatetime;rnadoquery1.Parameters[4].Direction:=pdinput;rnadoquery1.Parameters[4].Value:=strtodate(maskedit1.Text);rnadoquery1.Parameters.AddParameter;rnadoquery1.Parameters[5].Name:='username';rnadoquery1.Parameters[5].DataType:=ftstring;rnadoquery1.Parameters[5].Direction:=pdinput;rnadoquery1.Parameters[5].Value:=edit1.Text;rnadoquery1.ExecSQL;rnrnadoquery1.SQL.Clear;rnadoquery1.SQL.Add('insert into admin(name,pwd,purview,department,operater,date)values(:username,:password,:pur,:op,:lastdate)');rnadoquery1.Parameters.Clear;rn adoquery1.Parameters.AddParameter;rn adoquery1.Parameters[0].name:='username';rn adoquery1.Parameters[0].DataType:=ftstring;rn adoquery1.Parameters[0].Direction:=pdinput;rn adoquery1.Parameters[0].Value:=edit1.text;rn adoquery1.Parameters.AddParameter;rn adoquery1.Parameters[1].name:='password';rn adoquery1.Parameters[1].DataType:=ftstring;rn adoquery1.Parameters[1].Direction:=pdinput;rn adoquery1.Parameters[1].Value:=edit2.text;rn adoquery1.Parameters.AddParameter;rn adoquery1.Parameters[2].name:='pur';rn adoquery1.Parameters[2].DataType:=ftstring;rn adoquery1.Parameters[2].Direction:=pdinput;rn adoquery1.Parameters[2].Value:=edit5.text;rn adoquery1.Parameters.AddParameter;rn adoquery1.Parameters[3].name:='un';rn adoquery1.Parameters[3].DataType:=ftstring;rn adoquery1.Parameters[3].Direction:=pdinput;rn adoquery1.Parameters[3].Value:=edit3.Text;rn adoquery1.Parameters.AddParameter;rn adoquery1.Parameters[4].name:='operator';rn adoquery1.Parameters[4].DataType:=ftstring;rn adoquery1.Parameters[4].Direction:=pdinput;rn adoquery1.Parameters[4].Value:=edit4.text;rn adoquery1.Parameters.AddParameter;rn adoquery1.Parameters[5].name:='lastdate';rn adoquery1.Parameters[5].DataType:=ftdatetime;rn adoquery1.Parameters[5].Direction:=pdinput;rn adoquery1.Parameters[5].Value:=StrToDate(maskedit1.text);rn adoquery1.ExecSQL; 论坛

Message="INSERT INTO 语句语法错误。"

07-28

rn用户代码未处理 System.Data.OleDb.OleDbExceptionrn Message="INSERT INTO 语句的语法错误。"rn Source="Microsoft JET Database Engine"rn ErrorCode=-2147217900rn StackTrace:rn 在 System.Data.OleDb.OleDbCommand.ExecuteCommandTextErrorHandling(OleDbHResult hr)rn 在 System.Data.OleDb.OleDbCommand.ExecuteCommandTextForSingleResult(tagDBPARAMS dbParams, Object& executeResult)rn 在 System.Data.OleDb.OleDbCommand.ExecuteCommandText(Object& executeResult)rn 在 System.Data.OleDb.OleDbCommand.ExecuteCommand(CommandBehavior behavior, Object& executeResult)rn 在 System.Data.OleDb.OleDbCommand.ExecuteReaderInternal(CommandBehavior behavior, String method)rn 在 System.Data.OleDb.OleDbCommand.ExecuteNonQuery()rn 在 DBHelp.ExecuteNonQuery(String connectionString, String cmdText, OleDbParameter[] commandParameters) 位置 d:\leech\shipping\App_Code\DBHelp.cs:行号 38rn 在 admin_Icitem.btnSave_Click(Object sender, EventArgs e) 位置 d:\leech\shipping\admin\Icitem.aspx.cs:行号 42rn 在 System.Web.UI.WebControls.Button.OnClick(EventArgs e)rn 在 System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument)rn 在 System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument)rn 在 System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument)rn 在 System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData)rn 在 System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) 论坛

没有更多推荐了,返回首页