View Poll Results: Easiest way to connect to a MS Access DB

Voters
7. You may not vote on this poll
  • ODBC

    0 0%
  • ADODB

    2 28.57%
  • ADO

    5 71.43%
Results 1 to 6 of 6

Thread: [RESOLVED] ADODB/MS Access 97 conflicts

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Sep 2005
    Posts
    200

    Resolved [RESOLVED] ADODB/MS Access 97 conflicts

    ok I'm using an ADODB connection to connect VB6 to a MS Access 97 database. Now I converted the database from a MS Access 2003 database, and because of this I can not change the data in the database. My question is: can somone point me on how to set up an ODBC connection with VB to connect to a MS Access 2003 database so that I can manipulate the data?
    VB Code:
    1. [FONT=Lucida Console]'Create a new connection --
    2.         Set adoConnection = New ADODB.Connection
    3.        
    4.         'Create a new recordset --
    5.         Set adoRecordset = New ADODB.Recordset
    6.        
    7.         'Build our connection string to use when we open the connection --
    8.         connectString = "Provider=Microsoft.Jet.OLEDB.3.51;" _
    9.                          & "Data Source=C:\Documents and Settings\P6B0438\Desktop\CycleCount.mdb"
    10.        
    11.         adoConnection.Open connectString
    12.        
    13.         adoRecordset.Open "SECURITY", adoConnection
    14.         Do Until adoRecordset.EOF
    15.             If (adoRecordset!UserName = txtUserName.Text) Then
    16.                 Dim str As String
    17.                 str = txtOldPassword.Text
    18.                 If (adoRecordset!Password = txtOldPassword.Text) Then
    19.                      [B]'this line does not work
    20.                      adoRecordset!Password = txtNewPassword1.Text[/B]
    21.                 End If
    22.                 MsgBox ("The password should have been changed from " & str & " to " & adoRecordset!Password)
    23.                
    24.             End If
    25.             adoRecordset.MoveNext
    26.         Loop[/FONT]




    Edit: Added [vbcode][/vbcode] tags for clairty. - Hack
    Last edited by Hack; Sep 14th, 2005 at 01:44 PM.

  2. #2
    Giants World Champs!!!! Mark Gambo's Avatar
    Join Date
    Sep 2003
    Location
    Colorado
    Posts
    2,965

    Re: ADODB/MS Access 97 conflicts

    Take a look at the ADO/Access example in my signature
    Regards,

    Mark

    Please remember to rate posts! Rate any post you find helpful. Use the link to the left - "Rate this Post". Please use [highlight='vb'] your code goes in here [/highlight] tags when posting code. When a question you asked has been resolved, please go to the top of the original post and click "Thread Tools" then select "Mark Thread Resolved."


  3. #3
    PowerPoster Keithuk's Avatar
    Join Date
    Jan 2004
    Location
    Staffordshire, England
    Posts
    2,236

    Re: ADODB/MS Access 97 conflicts

    Where is DAO? And don't say its old. A pole should have all options.
    Keith

    I've been programming with VB for 25 years. Started with VB4 16bit Pro, VB5 Pro, VB6 Pro/Enterprise and now VB3 Pro. But I'm no expert, I'm still learning.

  4. #4

    Thread Starter
    Addicted Member
    Join Date
    Sep 2005
    Posts
    200

    Re: ADODB/MS Access 97 conflicts

    What is DAO?

  5. #5
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,974

    Re: ADODB/MS Access 97 conflicts

    DAO is the predecessor to ADO, and I certainly cannot advise it's use - I believe support for it has ended, or will soon. It also has less functionality than ADO.

    The trouble with your code above is with your "adoRecordset.Open " line, you have not specified enough parameters to be able to write to it. If you don't specify otherwise, you get a forward-only, read-only recordset.

    Try this instead:
    VB Code:
    1. adoRecordset.Open "SECURITY", adoConnection, adOpenDynamic, adLockOptimistic

  6. #6
    PowerPoster Keithuk's Avatar
    Join Date
    Jan 2004
    Location
    Staffordshire, England
    Posts
    2,236

    Re: ADODB/MS Access 97 conflicts

    Quote Originally Posted by manofsteel00
    What is DAO?
    DAO = Data Access Objects. The last version was 3.6 which will open an Access 2000 DB.

    It maybe old but you can still download v3.6 from M$.
    Last edited by Keithuk; Sep 14th, 2005 at 04:57 PM.
    Keith

    I've been programming with VB for 25 years. Started with VB4 16bit Pro, VB5 Pro, VB6 Pro/Enterprise and now VB3 Pro. But I'm no expert, I'm still learning.

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