Results 1 to 5 of 5

Thread: question on sql

Hybrid View

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Jun 2001
    Location
    CT
    Posts
    124

    Cool question on sql

    I have a tmpsql

    tmpsql = Select * From Customer where Customer.Customer_Name = "Jon"

    only problem is, u have to have the sql statement in " "
    and when it gets to the "Jon" it believes it's the end of the variable, how to I make vb include " in the string?
    Vini, Vidi, Vici!
    -----------------
    say this 5 times fast
    "I am not a pheasant plucker, I'm a pheasant plucker's son. I'm only plucking pheasants, till the pheasant plucker comes."

  2. #2
    PowerPoster
    Join Date
    Oct 2002
    Location
    British Columbia
    Posts
    9,758
    Use single quotes to surround your string criterias.

    VB Code:
    1. tmpsql = "Select * From Customer where Customer.Customer_Name = 'Jon'"

  3. #3
    Addicted Member
    Join Date
    Jul 2002
    Location
    BC, Canada
    Posts
    152
    Another way to put " into your strings is to use it twice.

    ie:
    VB Code:
    1. Dim str As String
    2. str = "My name is Bob ""Wild"" Smith"
    3. MsgBox str
    But brucevde is right in that you should use the single quotes ' around strings. I think some versions of SQL only use the single quotes. (But I have been known to be wrong.) However, it doesn't hurt to use them.

    Destined

  4. #4

    Thread Starter
    Lively Member
    Join Date
    Jun 2001
    Location
    CT
    Posts
    124

    Cool

    thanks that works, although in a msgbox it shows up as a ' and not a " but it works so who cares :-)
    Vini, Vidi, Vici!
    -----------------
    say this 5 times fast
    "I am not a pheasant plucker, I'm a pheasant plucker's son. I'm only plucking pheasants, till the pheasant plucker comes."

  5. #5
    Addicted Member
    Join Date
    Jul 2002
    Location
    BC, Canada
    Posts
    152
    Originally posted by Inimicum
    thanks that works, although in a msgbox it shows up as a ' and not a " but it works so who cares :-)
    I just tested mine (cut'n pasted into program) and it came out using "

    Oh well.

    Destined

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