Hi Everyone,
I am currently Working on a School Project which has the form of a stock update System. I am using an access 2007 DB and building my code in Visual Studio 2010. I am trying to get an Update Query to work and I am completely unsure on how to go about it.... Here is what I have so far.

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim con As New OleDbConnection
        Dim cmd As New OleDbCommand
        Dim Query As String

        Query = "update Prod_DB_Laminate_Raw set [Stock Level] = '" & TextBox1.Text & "where Laminate = " & ComboBox1.Text & ""
      
        con.Open()
        cmd = New OleDbCommand(Query, con)
        cmd.ExecuteNonQuery()
        cmd.Dispose()
        con.Close()

    End Sub

Is this the correct way of doing this or am I looking at the wrong thing entirely?

Many Thanks
Ziggy

Put a space between the quote and the word where
" where

When I do that, it then throws this error at me:
Syntax error in string in query expression '456 where Laminate = Mahogany'.
How do I solve this?

Change it to

Query = "update Prod_DB_Laminate_Raw set [Stock Level] = '" & TextBox1.Text & "' where Laminate = '" & ComboBox1.Text & "'"

Wnen you run into a problem like this it is best to display the actual query string as submitted to SQL. In most cases the error will be obvious. An extra line of

msgbox(Query)

Can open your eyes.

Thank You Very Much Reverend, I'm still pretty new at this, just trying to find my way

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.