Results 1 to 2 of 2

Thread: ADODB error (newbie)

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Sep 2002
    Posts
    146

    ADODB error (newbie)

    Code:
    Dim con As New ADODB.Connection
    
    
    
    
    
    
    Private Sub Form_Load()
    con.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Documents and Settings\User\Desktop\i-Analysis\Analysis.mdb;Persist "
    
    Dim rs As New ADODB.Recordset
    
    rs.Open "select * from IATestDetails", con, 3, 3, 1
    End Sub



    The table "IATestDetails" clearly exists in the database "Analysis.mdb"..


    What is the problem?
    Attached Images Attached Images  

  2. #2
    PowerPoster
    Join Date
    Feb 2006
    Location
    East of NYC, USA
    Posts
    5,691

    Re: ADODB error (newbie)

    Either you're looking at the wrong mdb file (when you're opening the connection) or the table name is spelled wrong. Or the fact that you ended the connection string prematurely may be causing a problem - it should end "... Persist Security Info=False"

    One hint, so you can read your code 6 months from now. You may remember what
    rs.Open "select * from IATestDetails", con, 3, 3, 1
    means now (I've been using ADO since it came out, and I couldn't guess), but
    rs.Open "select * from IATestDetails", con, adOpenStatic, adLockBatchOptimistic
    is much easier to read. (And adCmdText is the default for a recordset open, so you don't have to specify it.) Just pick from the choices VB's Intellisense gives you as you're typing the code.

    And never Dim X as New ... There's no way to recover that memory without rebooting the computer (it's called a "memory leak"). Dim X As ADODB ..., then Set X = New ADODB .... When you're done with it, Set X = Nothing, and you'll recover the memory. (Running a program that doesn't recover memory, over and over, can cause the computer to crash, even when the program is no longer running.)

    Someone named Beacon wrote a very good ADO tutorial. You should copy it and print it for future reference. Also, look in C:\Program Files\Microsoft Visual Studio\MSDN98\98VSa\1033\ for the file ADO200.CHM. It's Microsoft's help file for ADO.
    The most difficult part of developing a program is understanding the problem.
    The second most difficult part is deciding how you're going to solve the problem.
    Actually writing the program (translating your solution into some computer language) is the easiest part.

    Please indent your code and use [HIGHLIGHT="VB"] [/HIGHLIGHT] tags around it to make it easier to read.

    Please Help Us To Save Ana

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