Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: VB VB.NET
The line of the error is at "adptr.UpdateCommand.ExecuteNonQuery()" but I don't see anything wrong with the CommandText (UPDATE code):
 
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 7-Mar-13 17:19pm
Semeki259
Comments
GuyThiebaut at 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() & ""
ThePhantomUpvoter at 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

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

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.
  Permalink  

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

  Print Answers RSS
0 OriginalGriff 386
1 Marcin Kozub 225
2 Sergey Alexandrovich Kryukov 215
3 /\jmot 189
4 Praneet Nadkar 173
0 OriginalGriff 8,289
1 Sergey Alexandrovich Kryukov 7,407
2 DamithSL 5,624
3 Maciej Los 4,989
4 Manas Bhardwaj 4,986


Advertise | Privacy | Mobile
Web02 | 2.8.1411023.1 | Last Updated 9 Mar 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100