Click to See Complete Forum and Search --> : Another SQL query error


scottie_uk
April 29th, 2003, 12:49 PM
I get an error message asking for a semi-colon at the end of statment, but it's there. What is wrong.

This is an access database being accesses in vb.net
using this query:

Dim sqlquery2 As String = "INSERT INTO productFile( productID, Name, CostPrice, SalePrice, Type, ProductDisc, SupplierID, ServingsPerUnit) VALUES ( " & prodno & ", '" & prodName & "', " & costPrice & ", " & salePrice & ", '" & type & "', '" & prodDesc & "', " & supplier & ", " & prodServ & " ) WHERE productID = " & prodno & ";"


:confused:

Rube74
April 29th, 2003, 01:01 PM
Try to send your query string to a MsgBox to see what the actual query looks like.

scottie_uk
April 29th, 2003, 01:08 PM
Look at the JPG it looks fine to me

Rube74
April 29th, 2003, 01:11 PM
Yeah, it does look fine. Try double quotes around the strings... that might work...

scottie_uk
April 29th, 2003, 01:14 PM
I have double qutes arrount stings in the VALUES part, bo you mean also in the SELECT part??

Rube74
April 29th, 2003, 01:18 PM
I mean... instead of a single quote and a double quote, try two double quotes. I think that your problem may be that the single quotes aren't allowing Access to finish the string which may be why it's asking for the semi-colon.

So, your results should look like:

INSERT INTO Table1 (column1) VALUES ("value1")

rather than

INSERT INTO Table1 (column1) VALUES ('value1')

I seem to remember running into this same problem myself.

scottie_uk
April 29th, 2003, 01:20 PM
Hang on just fiqured it.

You cannot have a WHERE in an insert stament,

why I put it there in the first place beats me???

to many hour in front of my puter probably
:p

Rube74
April 29th, 2003, 01:21 PM
good point... you can't add a record and put conditions on it at the same time... :-)