Results 1 to 10 of 10

Thread: SQL statement and ADO

  1. #1
    Guest

    Talking

    (1) Can you guys check out this thread and try to answer it?
    http://forums.vb-world.net/showthrea...threadid=28698

    (2) I know what DAO is and how to use it, but can anyone explain to me what ADO is and how to use it?

    I posted the first wuestion in the Database section, but didn't get a lot of response.

    Thanks!

  2. #2
    Frenzied Member
    Join Date
    Aug 2000
    Posts
    1,539
    here you go

    SQL = "SELECT * FROM MyTable WHERE ID =2"

    if ID is a text field
    you go

    SQL = "SELECT * FROM MyTable WHERE ID = '2'"

    sql is almost identical accross all platforms, applications..

    second part:

    ADO is way of accessing db, DAO is too
    but MS wants you to use ADO from now on
    ado is faster, and its better because there is more support for it)

    there is a lot of threads explaining their differences..

  3. #3
    Guest
    kovan: It still returns only the first record with the specified ID
    Any ideas?

  4. #4
    Guest
    kovan: what references/components should I use for ADO? and what's the latest version?

  5. #5
    Fanatic Member
    Join Date
    Aug 2000
    Posts
    736
    If you are running VB6 with Service Pack 4, you should have ADO 2.5.

    The reference is "Microsoft ActiveX Data Objects 2.5 Library".

  6. #6
    Hyperactive Member Paul Warren's Avatar
    Join Date
    Jun 2000
    Location
    UK
    Posts
    282
    Sc0rp - How have you checked that only one record is coming back ? The SQL looks fine that everyone has provided. Try this and let us know the answer :

    Code:
    rsTemp.MoveLast
    MsgBox rsTemp.Recordcount
    If it returns 1 then check you're not running the SQL against a query which uses SELECT DISTINCT * FROM table because that may be filtering out the duplicate rows before your SQL is run against it.
    That's Mr Mullet to you, you mulletless wonder.

  7. #7
    Guest
    Oh.
    I didn't use the MoveLast method.
    Why do I have to do that?
    If I load a database using OpenDatabase the recordcount property returns the right value, even after MoveFirst, or MoveNext.

  8. #8
    Frenzied Member
    Join Date
    Aug 2000
    Posts
    1,539
    use the sql i gave
    and do the following
    Code:
    while not rs.eof
       listbox1.additem !Name
       rs.moveNext
    wend
    that will put all the names that sql returns

    you weren't looping
    you have to loop to get all


    [Edited by kovan on 08-30-2000 at 12:33 PM]

  9. #9
    Frenzied Member
    Join Date
    Aug 1999
    Location
    Santa Clara, Ca , 95058
    Posts
    1,105
    Kovan, you'll need a movenext in your while statement or it'll become an infinite loop...

  10. #10

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