FOS-Bret
asked on
"INSERT INTO" Command Help
I give up. I know this is something dumb, but I just can't figure it out.
I'm executing the following "INSERT INTO" statement on my (Jet) database.
INSERT INTO tblGrandLodgeCommunication s (MemberID, BackupName, Date, Communication) VALUES ('204', John H. Doe', '40174.8401551157', 'blah');
I've verified the name of the table and the names of the four fields within the table. The simple table schematic is in the image below.
I keep getting "Syntax error in INSERT INTO statement."
If it helps, I've also attached the output from clicking "Copy exception detail to clipboard."
Any help will be much appreciated.
Thanks,
Bret
tblGrandLodgeCommunications.jpg
ExceptionDetail.txt
I'm executing the following "INSERT INTO" statement on my (Jet) database.
INSERT INTO tblGrandLodgeCommunication
I've verified the name of the table and the names of the four fields within the table. The simple table schematic is in the image below.
I keep getting "Syntax error in INSERT INTO statement."
If it helps, I've also attached the output from clicking "Copy exception detail to clipboard."
Any help will be much appreciated.
Thanks,
Bret
tblGrandLodgeCommunications.jpg
ExceptionDetail.txt
INSERT INTO tblGrandLodgeCommunication s (MemberID, BackupName, Date, Communication) VALUES ('204', John H. Doe', '40174.8401551157', 'blah');
-->
INSERT INTO tblGrandLodgeCommunication s (MemberID, BackupName, Date, Communication) VALUES ('204', 'John H. Doe', '40174.8401551157', 'blah');
-->
INSERT INTO tblGrandLodgeCommunication
if you try this, maybe it works...
SQL = "INSERT INTO tblGrandLodgeCommunication s (MemberID, BackupName, Date) VALUES ('" & MyMemberID & "', '" & MyBackupName & "', '" & MyDateString & "')"
if it works the problem is in memo field...
SQL = "INSERT INTO tblGrandLodgeCommunication
if it works the problem is in memo field...
ASKER
HainKurt,
Thanks for the ultra quick reply. Unfortunately that was a typo on my part. I changed the name for the post and inadvertently deleted the tick mark before the name. The SQL being generated does include that tick mark.
Thanks for the ultra quick reply. Unfortunately that was a typo on my part. I changed the name for the post and inadvertently deleted the tick mark before the name. The SQL being generated does include that tick mark.
I thougt it is a type too, I checked the code and it looks ok... maybe the problem is on memo field, thats why, if you try above (do not include 4th column) and try to insert record we will be sure...
ASKER
I just tried that (without the memo field) and I still get the error. Bummer.
I just tried a query similar to yours on a Access db
insert into users (Company, LastName, FirstName, EMail) values ('North Star', 'Kurt', 'Hain', 'hainkuer@ee.com')
and it has an ID as autonumber like your table... no issues here...
and you are getting the error here :
MyCommand.ExecuteNonQuery( )
right?
insert into users (Company, LastName, FirstName, EMail) values ('North Star', 'Kurt', 'Hain', 'hainkuer@ee.com')
and it has an ID as autonumber like your table... no issues here...
and you are getting the error here :
MyCommand.ExecuteNonQuery(
right?
try adding ; at the end... who knows...
SQL = "INSERT INTO tblGrandLodgeCommunication s (MemberID, BackupName, Date, Communication) VALUES ('" & MyMemberID & "', '" & MyBackupName & "', '" & MyDateString & "', '" & MyCommunication & "');"
SQL = "INSERT INTO tblGrandLodgeCommunication
ASKER
I tried the ";" at the end. Still no luck.
Yes, I'm getting the error on the MyCommand.ExecuteNonQuery( ) statement.
Yes, I'm getting the error on the MyCommand.ExecuteNonQuery(
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
like Date ;)
ASKER
That was it. Thanks very much. I appreciate the help.
ASKER
Private Sub SaveCommunication(ByVal WhichCommunication As String)
Dim SQL As String
Dim MyConnection As OleDbConnection
Dim MyConnectionString As String
Dim MyCommand As New OleDbCommand
Dim FullName As String
Dim MyDateString As String
Dim MyMemberID As String
Dim MyBackupName As String
Dim MyCommunication As String
MyConnectionString = "Provider=Microsoft.Jet.OL
FullName = frmMain.grid1.Item("Masoni
If Trim(frmMain.grid1.Item("M
FullName &= Trim(frmMain.grid1.Item("M
End If
FullName &= frmMain.grid1.Item("LastNa
FullName = Trim(FullName)
MyMemberID = frmMain.grid1.Item("ID", frmMain.grid1.CurrentRow.I
MyBackupName = FullName
MyDateString = DateToDouble(DateTime.Now)
MyCommunication = WhichCommunication
SQL = "INSERT INTO tblGrandLodgeCommunication
Debug.Print(SQL)
MyConnection = New OleDbConnection(MyConnecti
MyCommand = New OleDbCommand
MyCommand.Connection = MyConnection
MyCommand.CommandText = SQL
MyCommand.Connection.Open(
MyCommand.ExecuteNonQuery(
MyCommand.Connection.Close
End Sub