You're at least missing the ending '-character at both SQL clauses.
Your code
" Where WatchID='" & cmbWatchId.Text
should be
" Where WatchID='" & cmbWatchId.Text & "'"
assuming WatchID is textual value. Otherwise remove '-character from WatchID='"
In your update clause
"',DescriptionOfWatch='" & txtDescription.Text & ",Price="
you're also missing one '-character. It should be
"',DescriptionOfWatch='" & txtDescription.Text & "',Price="
Teme64
Veteran Poster
1,031 posts since Aug 2008
Reputation Points: 218
Solved Threads: 203
Dump this SQL statement to immediate window
Dim a As String
a = "update Watches set WatchBrand='" & txtWatchBrand.Text & "',WatchModel='" & txtWatchModel.Text & _
"',Manufacturer='" & txtManufacturer.Text & "',CountryOfOrigin='" & txtCountryOfOrigin.Text & "',Type='" & _
cmbType.Text & "',DescriptionOfWatch='" & txtDescription.Text & _
"',Price=" & txtPrice.Text & "',PriceInclVat=" & txtPriceInclVat.Text & " Where WatchID='" & cmbWatchId.Text & "'"
Debug.Write(a)
and post the result.
You can also check yourself that none of the text variables contains '-character (apostrophe). In that case you have to add an extra '-char, like txtDescription.Text.Replace("'", "''").
BTW, do you use comma or dot as decimal separator?
Teme64
Veteran Poster
1,031 posts since Aug 2008
Reputation Points: 218
Solved Threads: 203
Then dump it to immediate window:
- move cursor to line Debug.Write(a)
- press F9 to toggle breakpoint on to that line
- run the app until it stops at that breakpoint
- open immediate window (press Ctrl+G if it isn't open)
- type to immediate window: ? a
- and press Enter
Now you should see your update statement. Check apostrophes and commas like I told in my previous post. If you can't spot any errors, copy update statement from the immediate window and post it here.
Teme64
Veteran Poster
1,031 posts since Aug 2008
Reputation Points: 218
Solved Threads: 203
post a helpful respond.
I already did :D I postedYou can also check yourself that none of the text variables contains '-character (apostrophe). In that case you have to add an extra '-char, like txtDescription.Text.Replace("'", "''").
You did have apostrophes in description field. Change ..."',DescriptionOfWatch='" & txtDescription.Text &... to ..."',DescriptionOfWatch='" & txtDescription.Text.Replace("'", "''") &... . If you have apostrophes in some other field too, use the same replace method.
HTH
Teme64
Veteran Poster
1,031 posts since Aug 2008
Reputation Points: 218
Solved Threads: 203
Hi! Nice to hear that you got answer to your problem. Could you please mark the thread as solved. Thank you!
Teme64
Veteran Poster
1,031 posts since Aug 2008
Reputation Points: 218
Solved Threads: 203