Click here to Skip to main content
15,881,700 members
Please Sign up or sign in to vote.
2.00/5 (1 vote)
See more:
The line of the error is at "adptr.UpdateCommand.ExecuteNonQuery()" but I don't see anything wrong with the CommandText (UPDATE code):

VB
Dim sql As String = "UPDATE NTIdb " & _
                           " SET ID='" & idT.Text() & "'" & _
                           ", Status='" & ComboBox1.SelectedItem() & "'" & _
                           ", DateDeliver='" & DateTimePicker1.Value() & "'" & _
                           ", Client='" & clientT.Text() & "'" & _
                           ", POrder='" & orderT.Text() & "'" & _
                           ", StoreCode='" & storeCT.Text() & "'" & _
                           ", StoreType='" & storeTT.Text() & "'" & _
                           ", ProdUsage='" & prodUT.Text() & "'" & _
                           ", ProdCategory='" & prodCT.Text() & "'" & _
                           ", Brand='" & brandT.Text() & "'" & _
                           ", Descrption='" & descT.Text() & "'" & _
                           ", Quantity='" & NumericUpDown1.Value() & "'" & _
                           ", MainUnitSerial='" & mainUST.Text() & "'" & _
                           ", HDD1='" & hdd1T.Text() & "'" & _
                           ", HDD2='" & hdd2T.Text() & "'" & _
                           ", OpticalDrive='" & odT.Text() & "'" & _
                           ", Monitor='" & monitorT.Text() & "'" & _
                           ", Keyboard='" & keyboardT.Text() & "'" & _
                           ", NetAdaptor='" & netAdaptorT.Text() & "'" & _
                           ", ProdKey='" & prodkeyT.Text() & "'" & _
                           ", WTYEnt='" & wtyET.Text() & "'" & _
                           ", AccExec='" & accexecT.Text() & "'" & _
                           ", SalesOrder='" & sOrderT.Text() & "'" & _
                           ", SalesInv='" & sInvT.Text() & "'" & _
                           ", DReceipt='" & dRecT.Text() & "'" & _
                           ", ReceibedBy='" & receivedT.Text() & "'" & _
                           ", Waybill='" & waybillT.Text() & "'" & _
                           ", DueDate='" & DateTimePicker2.Value() & "'" & _
                           ", WHERE ID=" & TextBox1.Tag() & ""

           Try
                cnn.Open()
                adptr.UpdateCommand = cnn.CreateCommand
                adptr.UpdateCommand.CommandText = sql
                adptr.UpdateCommand.ExecuteNonQuery()
                MsgBox("Data updated!")
                adptr.Dispose()
                cnn.Close()
            Catch ex As Exception
                MsgBox(ex.ToString)
            End Try
Posted
Comments
GuyThiebaut 9-Mar-13 7:12am    
One thing I have just spotted is that you have one too many commas.
The comma before the where clause needs to be removed and changed to:

" WHERE ID=" & TextBox1.Tag() & ""
[no name] 9-Mar-13 8:33am    
You do not see anything wrong with your query? Never ever use string concatenation to construct SQL queries. If you used proper parameterized queries, most likely you would have had a problem to begin with.

1 solution

Could you put a debug statement in to write out the sql string, and post the result(just be sure that it does not contain security sensitive information), so that we can see what is happening in the update statement - then we might know where the error is.

I also suggest that you read up on SQL injection attacks as if that code was in an application anyone trying an injection attack will may get access to your database.

Always use stored procedures and parameters.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900