fpineda101
Well-known member
Looking at some of the previous posts, I decided to try a suggestion of tech gnome to get the full error description. Below is what I got...
---------------------------
---------------------------
System.Data.OleDb.OleDbException: Syntax error in INSERT INTO statement.
at System.Data.OleDb.OleDbCommand.ExecuteCommandTextErrorHandling(Int32 hr)
at System.Data.OleDb.OleDbCommand.ExecuteCommandTextForSingleResult(tagDBPARAMS dbParams, Object& executeResult)
at System.Data.OleDb.OleDbCommand.ExecuteCommandText(Object& executeResult)
at System.Data.OleDb.OleDbCommand.ExecuteCommand(CommandBehavior behavior, Object& executeResult)
at System.Data.OleDb.OleDbCommand.ExecuteReaderInternal(CommandBehavior behavior, String method)
at System.Data.OleDb.OleDbCommand.ExecuteNonQuery()
at ATM_V2.Access.ExecuteSQL(String inSQL) in C:\VB Examples\ATM V2\Access.vb:line 44
at ATM_V2.ATM.SetAction_Deposit(Int32 keyEntry) in C:\VB Examples\ATM V2\ATM.vb:line 517
---------------------------
OK
---------------------------
My sql that gets error is this:
SQL = "INSERT INTO TRANSACTION (account_no, trans_dt, trans_amt, trans_bal) VALUES ('" & dt.account_no & "', '" & Format(dt.transaction_dt, "dd-MMM-yy") & "', '" & dt.transaction_amt & "', '" & dt.transaction_bal & "')"
I try this sql too and this works for some reason...
SQL = "INSERT INTO account (account_no, account_id, account_type, pin, last_login, title, account_name, balance) VALUES ('78901', '51234', 'CHECKING', '9876', '" & Format(Now, "dd-MMM-yy") & "', 'Mrs.', 'PINEDA', '100')"
The string is passed to a sub routine which executes UPDATE commands just fine as well as the INSERT to the ACCOUNT table. Below is the sub routine...
Public Sub ExecuteSQL(ByVal inSQL As String)
Dim accCON As New OleDbConnection
Dim accCOMMAND As New OleDbCommand
accCON = New OleDbConnection(ACCESS_CONNECT_STRING)
accCOMMAND.CommandText = inSQL
accCOMMAND.Connection = accCON
accCON.Open()
accCOMMAND.ExecuteNonQuery()
accCON.Close()
End Sub
Tech Gnome, if you are out there please help! Or anyone else would be greatly appreciated too! It doesnt make sense to me that the 2nd insert would work but not the first...
---------------------------
---------------------------
System.Data.OleDb.OleDbException: Syntax error in INSERT INTO statement.
at System.Data.OleDb.OleDbCommand.ExecuteCommandTextErrorHandling(Int32 hr)
at System.Data.OleDb.OleDbCommand.ExecuteCommandTextForSingleResult(tagDBPARAMS dbParams, Object& executeResult)
at System.Data.OleDb.OleDbCommand.ExecuteCommandText(Object& executeResult)
at System.Data.OleDb.OleDbCommand.ExecuteCommand(CommandBehavior behavior, Object& executeResult)
at System.Data.OleDb.OleDbCommand.ExecuteReaderInternal(CommandBehavior behavior, String method)
at System.Data.OleDb.OleDbCommand.ExecuteNonQuery()
at ATM_V2.Access.ExecuteSQL(String inSQL) in C:\VB Examples\ATM V2\Access.vb:line 44
at ATM_V2.ATM.SetAction_Deposit(Int32 keyEntry) in C:\VB Examples\ATM V2\ATM.vb:line 517
---------------------------
OK
---------------------------
My sql that gets error is this:
SQL = "INSERT INTO TRANSACTION (account_no, trans_dt, trans_amt, trans_bal) VALUES ('" & dt.account_no & "', '" & Format(dt.transaction_dt, "dd-MMM-yy") & "', '" & dt.transaction_amt & "', '" & dt.transaction_bal & "')"
I try this sql too and this works for some reason...
SQL = "INSERT INTO account (account_no, account_id, account_type, pin, last_login, title, account_name, balance) VALUES ('78901', '51234', 'CHECKING', '9876', '" & Format(Now, "dd-MMM-yy") & "', 'Mrs.', 'PINEDA', '100')"
The string is passed to a sub routine which executes UPDATE commands just fine as well as the INSERT to the ACCOUNT table. Below is the sub routine...
Public Sub ExecuteSQL(ByVal inSQL As String)
Dim accCON As New OleDbConnection
Dim accCOMMAND As New OleDbCommand
accCON = New OleDbConnection(ACCESS_CONNECT_STRING)
accCOMMAND.CommandText = inSQL
accCOMMAND.Connection = accCON
accCON.Open()
accCOMMAND.ExecuteNonQuery()
accCON.Close()
End Sub
Tech Gnome, if you are out there please help! Or anyone else would be greatly appreciated too! It doesnt make sense to me that the 2nd insert would work but not the first...