Hi I have an INSERT INTO SQL that keeps on retuning an Syntax error in Insert Into. I cant seam to see where the error is, can anyone Help.
This is my SQL.

Dim DesignSQL As String = "INSERT INTO Design_tbl (CustmrID,[User],Builder,Model,Type) values ('" & _
                    CustID & "', '" & username & "', '" & CmbBuilder.Text & "', '" & _
                    cmbModel.Text & "','" & cmbType.Text & "') "

Thanks

Hi I have an INSERT INTO SQL that keeps on retuning an Syntax error in Insert Into

You get that error when you execute the SQL clause? What is the exact error message that you get?

You are inserting all five values as a text. Is CustmrID field also textual (i.e. varchar or text)? If not, remove '-characters from around CustID variable.

Also, is it possible that any of the variables or combobox text's contains a '-character? If so, you have to replace it with two '-characters, like username.Replace("'", "''") .

Finally, use Debug.Print(DesignSQL) to see what the DesignSQL variable actually contains.

Thank you Teme64 for your reply.
The error I get is "Data type mismatch in criteria expression"
The values being entered is CustID =Integer,username = text,CmbBuilder=Text,cmbModel=test,cmbType=text.
The values being accepted by access db are CustID =Number,
username =Number,CmbBuilder=Text,cmbModel=test cmbType=number.
The way I have my db set is User,cmbbuilder,cmbmodel,cmbtype they are all combo boxes that are extracted for individual tables
the reason for this was because when I design this db I didn't Even dreamed of using visual basic. and I already have 8 months of data in it.
I hope you can help me.
THANKS AGAIN.

try this:

Dim DesignSQL As String = "INSERT INTO Design_tbl (CustmrID,[User],Builder,Model,Type) values ('" & _
                    CustID & "', '" & Val(username) & "', '" & CmbBuilder.Text & "', '" & _
                    cmbModel.Text & "','" & cmbType.Text & "') "

if username is a string and if in your database is number it will return value mismatched. so convert your string "username" to Val(username). That, if the string "username" are all in numeric datatype.

Thank you c0deFr3aK
I have tried your coed and it worked
tanks again

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.