Results 1 to 5 of 5

Thread: [RESOLVED] Fox Pro Database SQL when using variables

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Jun 2003
    Posts
    259

    Resolved [RESOLVED] Fox Pro Database SQL when using variables

    i have a vb.net 2010 app i trying to connect a dbf file. i think its a fox pro database. i can connect to it fine and get all data from a column just fine. the problem is when i use the WHERE clause i dont know how to surround the variable since i have never used this type of database before now. this is what i have

    Code:
    Dim oCmdSelect As New OleDbCommand("SELECT LASTNAME, FIRSTNAME FROM UPDATED WHERE LASTNAME = lstItems1.Items(x).ToString, FIRSTNAME = lstItems2.Items(x).ToString", oAccessConn)

    so the lstItems1.Items(x).ToString is a listbox entry. i basically have a list box with about 800 names. i what to open the database to see if they exist in it with i guess a while loop, not sure about that yet. but i have searched everywhere and i can find out how to surround the lstItems1.Items(x).ToString
    Last edited by seanwpb; Mar 1st, 2013 at 10:36 AM. Reason: typo

  2. #2
    Frenzied Member
    Join Date
    May 2006
    Location
    some place in the cloud
    Posts
    1,886

    Re: Fox Pro Database SQL when using variables

    Chr(39) & lstItems1.Items(x).ToString & Chr(39)
    JG


    ... If your problem is fixed don't forget to mark your threads as resolved using the Thread Tools menu ...

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Jun 2003
    Posts
    259

    Re: Fox Pro Database SQL when using variables

    JG,

    thanks for the quick reply. this is what i have and the error follows

    "SELECT LASTNAME, FIRSTNAME FROM UPDATED WHERE LASTNAME = Chr(39) & lstItems1.Items(x).ToString & Chr(39)"

    error: command contains unrecognized phrase/keyword. any ideas?

  4. #4
    Frenzied Member
    Join Date
    May 2006
    Location
    some place in the cloud
    Posts
    1,886

    Re: Fox Pro Database SQL when using variables

    Code:
    "SELECT LASTNAME, FIRSTNAME FROM UPDATED WHERE LASTNAME = " & Chr(39) & lstItems1.Items(x).ToString & Chr(39)
    JG


    ... If your problem is fixed don't forget to mark your threads as resolved using the Thread Tools menu ...

  5. #5

    Thread Starter
    Hyperactive Member
    Join Date
    Jun 2003
    Posts
    259

    Re: Fox Pro Database SQL when using variables

    that was it. thank you so much

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