Dawit Worku
Dawit Worku

Reputation: 1

Keep getting the following error Message=There was an error parsing the query. [ Token line number = 1,Token line offset = 85,Token in error = ) ]

This is what I am trying to do:

SQLStmt = String.Format( _
      "insert into Details (OrderId, GSId, Qty, Each, LedgerId) values ({0}, {1}, {2}, {3}, {4})", _
       OrderId, lblGSId.Text, Qty, txtEach.Text, lblLedger.Text)
    'Debug.Write("UpdateSQLStmt=" & SQLStmt & vbCrLf)
    Dim UpdateCommand As New SqlCeCommand(SQLStmt, Cnxn)
    UpdateOK = UpdateCommand.ExecuteNonQuery()

Upvotes: 0

Views: 137

Answers (1)

Guillaume Poussel
Guillaume Poussel

Reputation: 9822

Displaying the full query, after String.Format call could help you to find the issue. If you have any non-integer value in the query, make sure they are included in quotes. Also, make sure they are not empty.

For example, if LedgerId is empty, your query is:

 INSERT INTO Details (OrderId, GSId, Qty, Each, LedgerId) VALUES (42, 3, 5, 6, )
                                                                     No value ^

As you can see, this is an invalid query, that could lead to the error message you are seeing.

Upvotes: 3

Related Questions