Results 1 to 7 of 7

Thread: Copying date from DB to Var.

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Nov 1999
    Posts
    184
    I Need to Open the DB "C:\Client.mdb"
    In the "clients" table in the DB
    there is a row called "Date"
    I need to know how to copy the 1st record
    of that row to a var...

    Possable???

    Thankyou!
    Evan Duffield --------
    --- [email protected]
    - -
    VB6 - Learning Edition
    - -


  2. #2
    Serge's Avatar
    Join Date
    Feb 1999
    Location
    Scottsdale, Arizona, USA
    Posts
    2,744
    You can do something like this. This example is using ADO, so make reference appropriately:

    Code:
    Dim cn As New ADODB.Connection
    Dim rs As New ADODB.Recordset
    Dim dtDate As Date
    
    cn.Privider = "Microsoft.Jet.OLEDB.4.0"
    cn.Open "C:\Client.mdb", "admin", ""
    
    'Substitute MyDateField with the appropriate FieldName
    'and MyTable with the appropriate TableName
    rs.Open "Select Top 1 MyDateField From MyTable", cn, adOpenStatic
    
    If Not rs.EOF Then dtDate = rs(0)
    
    MsgBox dtDate
    
    rs.Close
    Set rs = Nothing
    cn.Close
    Set cn = Nothing

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Nov 1999
    Posts
    184

    Unhappy

    Dang..

    Ya know.. I honestly dont know DBs that well
    and when It gives me a error I cant tell whats
    wrong.
    It says I didnt define a Custom Type called
    ADODB.Connection.. What can I do.??

    Thankyou!
    Evan Duffield --------
    --- [email protected]
    - -
    VB6 - Learning Edition
    - -


  4. #4
    Serge's Avatar
    Join Date
    Feb 1999
    Location
    Scottsdale, Arizona, USA
    Posts
    2,744
    Select References from the Project menu.
    Set a check mark on the Microsoft ActiveX Data Objects 2.x Library. Click OK, run your program.

  5. #5

    Thread Starter
    Addicted Member
    Join Date
    Nov 1999
    Posts
    184

    Angry

    -->cn.Privider = "Microsoft.Jet.OLEDB.4.0"


    "Object doesnt support named arguments"


    ?? Huh??
    Evan Duffield --------
    --- [email protected]
    - -
    VB6 - Learning Edition
    - -


  6. #6
    Serge's Avatar
    Join Date
    Feb 1999
    Location
    Scottsdale, Arizona, USA
    Posts
    2,744
    Oops, that's just a typo.....change this:
    cn.Privider = "Microsoft.Jet.OLEDB.4.0"

    to this

    cn.Provider = "Microsoft.Jet.OLEDB.4.0"


  7. #7

    Thread Starter
    Addicted Member
    Join Date
    Nov 1999
    Posts
    184

    Angry

    More problems....

    "ADO could not find the specified provider"

    -->cn.Open "C:\ClientAlert\clients.mdb", "admin", ""

    thankyou....
    Evan Duffield --------
    --- [email protected]
    - -
    VB6 - Learning Edition
    - -


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