Results 1 to 4 of 4

Thread: SQL Incompatibility between DAO and ADO

  1. #1

    Thread Starter
    New Member
    Join Date
    Aug 2000
    Posts
    6

    Question

    I recently wrote a catalog application using DAO technology. I discovered that since the computer I was installing it on did not have an MS Access driver, the program would not function as it did on my home computer which has Access. A friend suggested that I use ADO. After laboriously changing the code in that direction, lo and behold, the SQL syntax was not acceptable to the compiler. Here are a couple of the SQL statements are there are in DAO format:

    Data1.RecordSource = "SELECT * FROM" & " " & cboTables.Text & " " & "WHERE" & " " & MyQuery

    Data1.RecordSource = "SELECT * FROM [" & cboTables.Text & "]" & " WHERE [" & cboFields.Text & "] LIKE '*" & txtSearch.Text & "'"

    Any suggestions on how I should convert them into proper ADO syntax? And where can I go to learn more about ADO SQL?

    Thanks,
    -Bob Smythe

  2. #2
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    Try these:
    Code:
    Data1.RecordSource = "SELECT * FROM " & cboTables.Text & " WHERE " & MyQuery
    
    Data1.RecordSource = "SELECT * FROM " & cboTables.Text & " WHERE " & cboFields.Text & " LIKE ""*" & txtSearch.Text & """"
    I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
    -- Linus Torvalds

  3. #3
    Guru Clunietp's Avatar
    Join Date
    Oct 1999
    Location
    USA
    Posts
    1,844
    Your syntax is fine, except a minor difference between ADO and DAO are the wildcard characters.

    DAO uses the asterisk ( * )

    while

    ADO uses the percent ( % )

    as their respective wildcards. Replace your asterisk with a percent and you should be fine

  4. #4
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    *oops* sorry...I did know that...but I forgot. Thanks for pointing it out Clunietp...I'll know next time I need to use ADO (I don't use it much, but didn't have too many problems).
    I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
    -- Linus Torvalds

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