Am getting problem with this update statement:
Here's the code:

Private Sub cmdUpdate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdUpdate.Click
        Try
            Dim com As New OleDbCommand
            com.Connection = con
            com.CommandText = "Update Sales set CustomerId='" & txtCustomerId1.Text & "',WatchId='" & txtWatchId1.Text & _
            "',Dateofsales='" & txtDate.Text & "',Quantity='" & txtQuantity.Text & "',Priceperunit='" & txtprice1.Text & "',TotalPrice='" & txtTotal.Text & _
            "',TotalPriceInclVat='" & txttotalpriceinclvat1.Text & "'Where WatchID='" & txtSalesId.Text & "'"
            com.ExecuteNonQuery()
            MsgBox("Record Updated")
            Call populate()
        Catch
            MsgBox("Error")
        End Try
    End Sub

error saying (no value given for one or more required parameters)
please help
thanks

Recommended Answers

All 4 Replies

That all depends on what your final query is evaluated as. We can't see what your user input is. One piece of advise: use parameterized queries!
http://forums.devx.com/showthread.php?t=160026

Put a break point on the line com.ExecuteNonQuery() and evaluate the value of com.CommandText and post it back here.

@manutd4file : error saying (no value given for one or more required parameters)

--- Compare columns names with your fields (columns) of database's table.

As suggested by Scott Knake, find what the final SQL is, copy that and paste in query analyzer to see if that by itself. Syntax error given there are more informative. Other thing he suggested is paramterize your query. Otherwise, data with single quote will bomb the query, worst yet, it is prone to security flaw (google SQL injection)

Try displaying the SQL as a Label in your form to see if some of the txt.Text is null.

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.