Search code examples
sqlvb.netwhere-clauseinsert-intooledbcommand

Missing semicolon (;) at end of SQL statement. Semicolon already exists


I keep getting this error Missing semicolon (;) at end of SQL statement. when I run this code:

Dim cmd3 As OleDbCommand = New OleDbCommand("INSERT INTO Tickers (Quarter_Balance_Sheets) VALUES (Scrapalbe) WHERE Ticker = A;", con)
cmd3.ExecuteNonQuery()

What am I doing wrong?


Solution

  • Edited..

    Sorry. After reading again you cannot use WHERE on an INSERT statement, loose the WHERE clause or make an UPDATE statement.

    INSERT INTO ... WHERE is not a valid query.

    If the insert you've posted has correct values and columns, the update should be:

    Dim cmd3 As OleDbCommand = New OleDbCommand("UPDATE Tickers SET Quarter_Balance_Sheets = 'Scrapalbe' WHERE Ticker = 'A';", con)
    cmd3.ExecuteNonQuery()