0

I do not understand what I am doing wrong!

Protected Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
    Dim con As New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Users\stagiaire\Desktop\App_Web.MDB")

    Try
        con.Open()
    Catch ex As Exception
        Response.Write("<script language=""javascript"">alert('Pas de Connexion');</script>")

    End Try

    Dim da As New OleDb.OleDbDataAdapter("select * from stats", con)
    Dim ds As New DataSet
    da.Fill(ds)

    Dim aString As String
    Dim num_off As String
    aString = CType(Site1.nom, String)
    num_off = CType(WebForm1.num_of, String)
   
    Dim cmd As OleDbCommand = New OleDbCommand(String.Concat("insert into  [stats]([op_10]) Values (" & 1 & ") WHERE ( [numero_of ]='" & num_off & "' )"), con)
    Dim drlog As OleDbDataReader = cmd.ExecuteReader
    If (drlog.Read() = True) Then
        cmd.ExecuteNonQuery()
        cmd.Dispose()
    End If

    Me.Visible = False

    Response.Redirect("WebForm3.aspx")
End Sub

the translation of the error is: a semicolon is missing at the end of the instruction enter image description here

3
  • 4
    What do you expect to happen? INSERT INTO ... VALUES ... inserts a new row, what's that WHERE supposed to do? Do you mean to use UPDATE instead of INSERT? Commented Nov 8, 2021 at 9:40
  • 1
    You have [numero_of ]. Do you really have a trailing space in your column name? Commented Nov 8, 2021 at 10:07
  • Even Access and ODBC know about parameters. Please use them to prevent all sorts of issues (except wrong statements) Commented Nov 8, 2021 at 10:11

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.