[RESOLVED] SQLite query with combobox selected item
I am trying to update a SQLite database table with values selected from comboboxes in VB.Net.
The first part of the query works, but if I include a where statement I get the following error : 'SQL logic error
near "Where": syntax error'
I have tried .selected text, but the error persists. What am I missing ?
Code:
Dim opdragKopersWatBotteleer As New SQLiteCommand
opdragKopersWatBotteleer.Connection = konneksie
opdragKopersWatBotteleer.CommandText = " Update Verkope " &
"set Gebottel = ( '" & BottelComboBox.SelectedItem & " ' " &
"Where verkope.DebiteurNaam = '" & KoperComboBox.SelectedItem & "' )"
opdragKopersWatBotteleer.ExecuteNonQuery()
Regards
Re: SQLite query with combobox selected item
Try this...
Code:
opdragKopersWatBotteleer.CommandText = " Update Verkope " &
"set Gebottel = ( '" & BottelComboBox.Text & "' " &
"Where verkope.DebiteurNaam = '" & KoperComboBox.Text & "' )"
verkope.DebiteurNaam???
Wouldn't that be just...
DebiteurNaam
???
Re: SQLite query with combobox selected item
Hi .paul
Thank you for replying. I have changed the .SelectedItem to .text
I have also tried DebiteurNaam in stead of verkope.DebiteurNaam.
I still get the error message.
Regards
Re: SQLite query with combobox selected item
What is the value of KoperComboBox.Text (or .SelectedItem.totext()) What is stored in DebiteurNaam? Can you look in the DB for the actual value selected? Have you put a breakpoint on the code and seen what the query is actually sending to the database? Copy that and execute it on the database?
Re: SQLite query with combobox selected item
Code:
" Update Verkope " &
"set Gebottel = ( '" & BottelComboBox.SelectedItem & " ' " &
"Where verkope.DebiteurNaam = '" & KoperComboBox.SelectedItem & "' )"
What's with the parenthesis?
Essentially your SQL looks like this:
Code:
Update Verkope
set Gebottel = ( 'something '
Where verkope.DebiteurNaam = 'SomethingElse' )
That's invalid syntax...
Try getting rid of the parens all together:
Code:
" Update Verkope " &
"set Gebottel = '" & BottelComboBox.SelectedItem & " ' " &
"Where verkope.DebiteurNaam = '" & KoperComboBox.SelectedItem & "'"
-tg
Re: SQLite query with combobox selected item
Thank you for replying. The issue was resolved by technome below.
Re: SQLite query with combobox selected item
Thank you techgnome. Problem solved. Also thank you for explaining what the SQL essentially looks like.
By the way breed is that fantastic dog on your avatar?
Regards
Re: [RESOLVED] SQLite query with combobox selected item
TG’s avatar looks like a German Shepherd, or a Huskie
Re: [RESOLVED] SQLite query with combobox selected item
Quote:
Originally Posted by
GideonE
Thank you techgnome. Problem solved. Also thank you for explaining what the SQL essentially looks like.
By the way breed is that fantastic dog on your avatar?
Regards
Quote:
Originally Posted by
.paul.
TG’s avatar looks like a German Shepherd, or a Huskie
That's Everest from a year or so ago... when he was a pup (he's 3 now) ... He's an Alaskan Malamute.... cousin to the Husky but about 3 times bigger. He tops the scales at 110pounds.
-tg
Re: [RESOLVED] SQLite query with combobox selected item