Results 1 to 6 of 6

Thread: SQL syntax (beginner)

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Jan 2000
    Location
    treehouse
    Posts
    106

    Post

    I am trying to write an SQL statement and I can't get the syntax right for it to work. Is there a site that I can learn the SQL syntax? Thanks

    Here's the Function:

    Public Function GetClient(sClientName As String) As String
    Dim sSQL As String
    Dim sName As String
    sSQL = "SELECT * From Customers " & "WHERE Customers.Contact Name = '" & sClientName & "'"

    Set rs = MyDb.OpenRecordse (sSQL,dbOpenDynaset)


    rs.Close
    End Function

    [This message has been edited by bontyboy (edited 02-15-2000).]

  2. #2
    Guest

    Post

    sSQL = "SELECT * From Customers "
    sSQL = sSQL & "WHERE Contact Name = '"
    sSQL = sSQL & sClientName & "'"

    check an make sure there is/isn't a space in contact name field



    [This message has been edited by BG (edited 02-15-2000).]

  3. #3
    Guru Clunietp's Avatar
    Join Date
    Oct 1999
    Location
    USA
    Posts
    1,844

    Post

    Change Contact Name to [Contact Name]

    (use brackets for fields with spaces)

    SQL tutorial @ http://w3.one.net/~jhoffman/sqltut.htm

  4. #4
    New Member
    Join Date
    Feb 2000
    Posts
    5

    Post

    Try using "LIKE" instead of =

  5. #5
    Lively Member
    Join Date
    Aug 1999
    Location
    SLOVENIA, Europe
    Posts
    110

    Post

    That must work.

    dim MyDb as Database
    dim RS as recordset

    set MyDb=OpenDatabase("c:\db.mdb")
    sSQL="SELECT * FROM Customers where Contact_Name=' " & sClientName & " ' "
    set RS =MyDb.OpenRecordset(sSQL,dbOpenDynaset)

    ' I'm not shure that SQL allows space in field name ("Contact Name") so use field name like Contact_name or use brackets.

  6. #6
    Hyperactive Member Gimpster's Avatar
    Join Date
    Oct 1999
    Location
    Redmond, WA 98052
    Posts
    331

    Post

    Also, here is a great site for a quick overview of SQL and how to use it. Print it out and have it by your computer whenever you are going to be using SQL.

    ------------------
    Ryan

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