M
me
This is driving me insane!!
I have a very simple Insert statement that is blowing out with a Syntax
error. First, here is my code - I have stripped out all of the dynamic
column names and hard-coded the values just to try and identify the problem:
Dim myConn1 As New OleDbConnection(AppSettings("myConnectionString"))
Dim mySQL1 As String = "INSERT INTO SECTION (ClientID, TownID ) VALUES (
'460', '4' )"
Dim cmd1 As New OleDbCommand(mySQL1, myConn1)
myConn1.Open()
cmd1.ExecuteNonQuery()
myConn1.Close()
I have tried removing the single quotes, putting brackets around the column
names, and all to no avail. I have also verified security rights on the
database and actually have a very similar Insert statement that runs before
this page that works just fine?!? Here is the error page I am getting:
Server Error in '/myApp' Application.
--------------------------------------------------------------------------------
Syntax error in INSERT INTO statement.
Description: An unhandled exception occurred during the execution of the
current web request. Please review the stack trace for more information
about the error and where it originated in the code.
Exception Details: System.Data.OleDb.OleDbException: Syntax error in INSERT
INTO statement.
Source Error:
Line 75: myConn1.Open()
Line 76: cmd1.ExecuteNonQuery()
Line 77: myConn1.Close()
Source File: D:\Inetpub\myApp\addSection.aspx.vb Line: 76
Stack Trace:
[OleDbException (0x80040e14): Syntax error in INSERT INTO statement.]
System.Data.OleDb.OleDbCommand.ExecuteCommandTextForSingleResult(tagDBPARAMS
dbParams, Object& executeResult) +267
System.Data.OleDb.OleDbCommand.ExecuteCommandText(Object& executeResult)
+192
System.Data.OleDb.OleDbCommand.ExecuteCommand(CommandBehavior behavior,
Object& executeResult) +48
System.Data.OleDb.OleDbCommand.ExecuteReaderInternal(CommandBehavior
behavior, String method) +106
System.Data.OleDb.OleDbCommand.ExecuteNonQuery() +108
myApp.addSection.button1_Click(Object sender, EventArgs e) in
D:\Inetpub\wls2\addSection.aspx.vb:76
System.Web.UI.WebControls.Button.OnClick(EventArgs e) +105
System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument)
+107
System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String
eventArgument) +7
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler
sourceControl, String eventArgument) +11
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +33
System.Web.UI.Page.ProcessRequestMain(Boolean
includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +5102
I have a very simple Insert statement that is blowing out with a Syntax
error. First, here is my code - I have stripped out all of the dynamic
column names and hard-coded the values just to try and identify the problem:
Dim myConn1 As New OleDbConnection(AppSettings("myConnectionString"))
Dim mySQL1 As String = "INSERT INTO SECTION (ClientID, TownID ) VALUES (
'460', '4' )"
Dim cmd1 As New OleDbCommand(mySQL1, myConn1)
myConn1.Open()
cmd1.ExecuteNonQuery()
myConn1.Close()
I have tried removing the single quotes, putting brackets around the column
names, and all to no avail. I have also verified security rights on the
database and actually have a very similar Insert statement that runs before
this page that works just fine?!? Here is the error page I am getting:
Server Error in '/myApp' Application.
--------------------------------------------------------------------------------
Syntax error in INSERT INTO statement.
Description: An unhandled exception occurred during the execution of the
current web request. Please review the stack trace for more information
about the error and where it originated in the code.
Exception Details: System.Data.OleDb.OleDbException: Syntax error in INSERT
INTO statement.
Source Error:
Line 75: myConn1.Open()
Line 76: cmd1.ExecuteNonQuery()
Line 77: myConn1.Close()
Source File: D:\Inetpub\myApp\addSection.aspx.vb Line: 76
Stack Trace:
[OleDbException (0x80040e14): Syntax error in INSERT INTO statement.]
System.Data.OleDb.OleDbCommand.ExecuteCommandTextForSingleResult(tagDBPARAMS
dbParams, Object& executeResult) +267
System.Data.OleDb.OleDbCommand.ExecuteCommandText(Object& executeResult)
+192
System.Data.OleDb.OleDbCommand.ExecuteCommand(CommandBehavior behavior,
Object& executeResult) +48
System.Data.OleDb.OleDbCommand.ExecuteReaderInternal(CommandBehavior
behavior, String method) +106
System.Data.OleDb.OleDbCommand.ExecuteNonQuery() +108
myApp.addSection.button1_Click(Object sender, EventArgs e) in
D:\Inetpub\wls2\addSection.aspx.vb:76
System.Web.UI.WebControls.Button.OnClick(EventArgs e) +105
System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument)
+107
System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String
eventArgument) +7
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler
sourceControl, String eventArgument) +11
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +33
System.Web.UI.Page.ProcessRequestMain(Boolean
includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +5102