Syntax Error in WHERE clause?
Posted on 2012-03-19
We're creating a web application with VS 2010 using Visual Basic.
We'd like to update an access database table using OldeDb...
For some reason, when we run the code, the program hanged and a message: "syntax error in WHERE clause".
We've checked again and again the statement string but could not find any error. It's likely that we missed something.
Would you help to look into the code and tell us what's wrong.
Thanks a lot,
' Set up the connection to connect to the ACCESS database
adbProvider = "Provider=Microsoft.ACE.OLEDB.12.0;"
adbDataSource = "Data Source =
Dim adbConnectionStr As String
adbConnectionStr = adbProvider & adbDataSource
adbConnection.ConnectionString = adbConnectionStr
Dim adbOrderID As String
Dim adbAmount As Double
Dim adbTax As Double
Dim adbCmdStr As String
adbOrderID = TextBox1.Text.ToString()
adbAmount = Convert.ToDouble(TextBox2.Text.ToString())
adbTax = Convert.ToDouble(TextBox3.Text.ToString())
adbCmdStr = "UPDATE vb_access_db3_tb2 SET Amount = " &
adbAmount & ", Tax = " & adbTax & " WHERE Order ID = '" & adbOrderID &
adbCommand = New OleDbCommand(adbCmdStr, adbConnection)
Catch ex As Exception