CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 8 of 8
  1. #1
    Join Date
    Mar 2003
    Location
    Cardiff and Oxford
    Posts
    44

    Another SQL query error

    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 & ";"



  2. #2
    Join Date
    Feb 2003
    Posts
    51
    Try to send your query string to a MsgBox to see what the actual query looks like.

  3. #3
    Join Date
    Mar 2003
    Location
    Cardiff and Oxford
    Posts
    44
    Look at the JPG it looks fine to me
    Attached Images Attached Images

  4. #4
    Join Date
    Feb 2003
    Posts
    51
    Yeah, it does look fine. Try double quotes around the strings... that might work...

  5. #5
    Join Date
    Mar 2003
    Location
    Cardiff and Oxford
    Posts
    44
    I have double qutes arrount stings in the VALUES part, bo you mean also in the SELECT part??

  6. #6
    Join Date
    Feb 2003
    Posts
    51
    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.

  7. #7
    Join Date
    Mar 2003
    Location
    Cardiff and Oxford
    Posts
    44
    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

  8. #8
    Join Date
    Feb 2003
    Posts
    51
    good point... you can't add a record and put conditions on it at the same time... :-)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured