-
Oct 29th, 2020, 03:28 AM
#1
Thread Starter
Addicted Member
[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
-
Oct 29th, 2020, 03:34 AM
#2
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
???
- Coding Examples:
- Features:
- Online Games:
- Compiled Games:
-
Oct 29th, 2020, 06:42 AM
#3
Thread Starter
Addicted Member
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
-
Oct 29th, 2020, 07:18 AM
#4
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?
Sometimes the Programmer
Sometimes the DBA
Mazz1
-
Oct 29th, 2020, 07:28 AM
#5
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
-
Oct 29th, 2020, 01:25 PM
#6
Thread Starter
Addicted Member
Re: SQLite query with combobox selected item
Thank you for replying. The issue was resolved by technome below.
-
Oct 29th, 2020, 01:34 PM
#7
Thread Starter
Addicted Member
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
-
Oct 29th, 2020, 02:12 PM
#8
Re: [RESOLVED] SQLite query with combobox selected item
TG’s avatar looks like a German Shepherd, or a Huskie
- Coding Examples:
- Features:
- Online Games:
- Compiled Games:
-
Oct 29th, 2020, 11:36 PM
#9
Re: [RESOLVED] SQLite query with combobox selected item
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
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
-
Oct 30th, 2020, 03:02 AM
#10
Re: [RESOLVED] SQLite query with combobox selected item
- Coding Examples:
- Features:
- Online Games:
- Compiled Games:
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|