Results 1 to 9 of 9

Thread: [RESOLVED] Cannot connect Access 2003 to VB6

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Nov 2006
    Posts
    110

    Resolved [RESOLVED] Cannot connect Access 2003 to VB6

    Hi

    Can anyone tell me how i can get around with this piece of code.
    Everything seems to be correct but when the program reaches cn.open it shows an error message saying "Authentication Failed". I have used no password and username. I've even tried creating different version of Access format (97 and 2000) but still it gives the same error. I've been stuck with this problem for two days.
    Can anyone please help me with the below code.

    VB Code:
    1. Private Sub Form_Load()
    2.     Me.MousePointer = 11 'this makes the mouse pointer the hourglass
    3.    
    4.     Set cn = New ADODB.Connection
    5.     cn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
    6.         "D:\Usama\db\db97.mdb"
    7.        
    8.     cn.Open
    9.    
    10.     Set rs = New ADODB.Recordset
    11.    
    12.     rs.Open "ChkList", cn, adOpenKeyset, adLockPessimistic, adCmdTable
    13.     rs.MoveFirst
    14.     Do Until rs.EOF = True
    15.         cn.AddItem rs.Fields("Field1")
    16.         rs.MoveNext
    17.     Loop
    18.        
    19.     rs.MoveFirst
    20.     fillFields
    21.    
    22.     Me.MousePointer = 0 'sets the mouse pointer to the normal arrow
    23.    
    24. End Sub

    Thanks

  2. #2
    VB Guru ganeshmoorthy's Avatar
    Join Date
    Dec 2005
    Location
    Sharjah, United Arab Emirates
    Posts
    3,031

    Re: Cannot connect Access 2003 to VB6

    try this connection string
    VB Code:
    1. Cn.Open "Driver=Microsoft Access Driver (*.mdb);DBQ=D:\Usama\db\db97.mdb;PWD=;"
    If an answer to your question has been helpful, then please, Rate it!

    Have done Projects in Access and Member management systems using BioMetric devices, Smart cards and BarCodes.


  3. #3
    Banned randem's Avatar
    Join Date
    Oct 2002
    Location
    Maui, Hawaii
    Posts
    11,385

    Re: Cannot connect Access 2003 to VB6

    Your connection string is not complete... see my signature...Connection Strings for more help

  4. #4

    Thread Starter
    Lively Member
    Join Date
    Nov 2006
    Posts
    110

    Re: Cannot connect Access 2003 to VB6

    When i tried your line of code it gave a new error saying "cannot find installable code ISAM"


    I also went to that site connection string but didnt really understand how to work it out



    any other suggestions?

  5. #5
    VB Guru ganeshmoorthy's Avatar
    Join Date
    Dec 2005
    Location
    Sharjah, United Arab Emirates
    Posts
    3,031

    Re: Cannot connect Access 2003 to VB6

    I just changed yours, try this...
    VB Code:
    1. cn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
    2.         "Data Source=D:\Usama\db\db97.mdb;User ID=;Password =;"
    If an answer to your question has been helpful, then please, Rate it!

    Have done Projects in Access and Member management systems using BioMetric devices, Smart cards and BarCodes.


  6. #6
    Banned randem's Avatar
    Join Date
    Oct 2002
    Location
    Maui, Hawaii
    Posts
    11,385

    Re: Cannot connect Access 2003 to VB6

    That line did not work because it is attempting to use an ODBC connection you want an OLEDB connection

    Try:
    VB Code:
    1. Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:\Usama\db\db97.mdb;User Id=admin;Password=;

  7. #7

    Thread Starter
    Lively Member
    Join Date
    Nov 2006
    Posts
    110

    Re: Cannot connect Access 2003 to VB6

    hey thanks alot guys

    i just remembered that just yesterday someone told me that I could use Access 2003 file and it would run. A little earlier it just struck me that after making the new Access 2003 file I haven't actually again added the new updated file to the ODBC from the control panel. After doing that the connection seem to work now. But now there is a new problwm at the below line.

    VB Code:
    1. cn.AddItem rs.Fields("CHKList_Id")

    Do you know what the problem is. It says: The microsoft jet database engine cannot find the input table or query 'AddItem'. Make sure it exists and that its name is spelled correctly.


    Now What??

  8. #8
    Banned randem's Avatar
    Join Date
    Oct 2002
    Location
    Maui, Hawaii
    Posts
    11,385

    Re: Cannot connect Access 2003 to VB6

    You really should get away from using ODBC unless it is absolutely needed...

  9. #9

    Thread Starter
    Lively Member
    Join Date
    Nov 2006
    Posts
    110

    Re: Cannot connect Access 2003 to VB6

    Hey guys .... just to let you know i have solved the problem ..


    actulally i was following a tutorial and it had the wrong controld name there. so i just figured it shouldn't be like that. - its suppose to be a combo which dds items.

    Thanks alot anywas fellows you guys have been a great help

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