Chris Jones
asked on
i have an issue with my sql statement
hllo i have a vb app and i have a issue with my sql insert statement can anyone help
STATEMENt
Dim cmd As New OleDb.OleDbCommand("INSERT INTO item ('Barcode','Type','Name',' Date','Com ments') VALUES (" & typebind.Text & "," & barcode.Text & "," & name.Text & "," & date1.Text & "," & comments.Text & ")", con)
STATEMENt
Dim cmd As New OleDb.OleDbCommand("INSERT
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
What database platform are you going to? It appears to be SQL Server, but just to make sure.
Either way, it appears the platform you are using is like SQL Server in that it uses single quotes (') for string literals; therefore, in your values portion of the insert you must wrap your data coming from VB variables with single quotes like this:
(column names should not have wrapped unless this is MySQL and you meant ` instead of '. You can use [] or "" for columns in SQL Server)
Either way, it appears the platform you are using is like SQL Server in that it uses single quotes (') for string literals; therefore, in your values portion of the insert you must wrap your data coming from VB variables with single quotes like this:
(column names should not have wrapped unless this is MySQL and you meant ` instead of '. You can use [] or "" for columns in SQL Server)
Dim cmd As New OleDb.OleDbCommand("INSERT INTO item ([Type],[Barcode],[Name],[Date],[Comments]) VALUES ('" & typebind.Text & "','" & barcode.Text & "','" & name.Text & "','" & date1.Text & "','" & comments.Text & "')", con)
ASKER
thanks i still have other issues but this fixed my problem
thank you
thank you
I posted too slow and twice somehow. Anyway, you had Barcode listed first and are putting type in first in values -- Note that was changed above in mine as well.
ASKER
great answers it was a not so smart post
>> great answers it was a not so smart post
Small errors/problems make us loose hours :)
Small errors/problems make us loose hours :)
ASKER