Results 1 to 10 of 10

Thread: [RESOLVED] SQLite query with combobox selected item

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Nov 2016
    Location
    South Africa
    Posts
    141

    Resolved [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

  2. #2
    eXtreme Programmer .paul.'s Avatar
    Join Date
    May 2007
    Location
    Chelmsford UK
    Posts
    25,464

    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

    ???

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Nov 2016
    Location
    South Africa
    Posts
    141

    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

  4. #4
    A SQL Server fool GaryMazzone's Avatar
    Join Date
    Aug 2005
    Location
    Dover,NH
    Posts
    7,495

    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

  5. #5
    Smooth Moperator techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,532

    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
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  6. #6

    Thread Starter
    Addicted Member
    Join Date
    Nov 2016
    Location
    South Africa
    Posts
    141

    Re: SQLite query with combobox selected item

    Thank you for replying. The issue was resolved by technome below.

  7. #7

    Thread Starter
    Addicted Member
    Join Date
    Nov 2016
    Location
    South Africa
    Posts
    141

    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

  8. #8
    eXtreme Programmer .paul.'s Avatar
    Join Date
    May 2007
    Location
    Chelmsford UK
    Posts
    25,464

    Re: [RESOLVED] SQLite query with combobox selected item

    TG’s avatar looks like a German Shepherd, or a Huskie

  9. #9
    Smooth Moperator techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,532

    Re: [RESOLVED] SQLite query with combobox selected item

    Quote Originally Posted by GideonE View Post
    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. View Post
    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
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  10. #10
    eXtreme Programmer .paul.'s Avatar
    Join Date
    May 2007
    Location
    Chelmsford UK
    Posts
    25,464

    Re: [RESOLVED] SQLite query with combobox selected item


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
  •  



Click Here to Expand Forum to Full Width