|
-
Dec 1st, 2006, 11:08 PM
#1
Thread Starter
Lively Member
[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:
Private Sub Form_Load()
Me.MousePointer = 11 'this makes the mouse pointer the hourglass
Set cn = New ADODB.Connection
cn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"D:\Usama\db\db97.mdb"
cn.Open
Set rs = New ADODB.Recordset
rs.Open "ChkList", cn, adOpenKeyset, adLockPessimistic, adCmdTable
rs.MoveFirst
Do Until rs.EOF = True
cn.AddItem rs.Fields("Field1")
rs.MoveNext
Loop
rs.MoveFirst
fillFields
Me.MousePointer = 0 'sets the mouse pointer to the normal arrow
End Sub
Thanks
-
Dec 1st, 2006, 11:16 PM
#2
Re: Cannot connect Access 2003 to VB6
try this connection string
VB Code:
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.
-
Dec 1st, 2006, 11:17 PM
#3
Re: Cannot connect Access 2003 to VB6
Your connection string is not complete... see my signature...Connection Strings for more help
-
Dec 1st, 2006, 11:23 PM
#4
Thread Starter
Lively Member
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?
-
Dec 1st, 2006, 11:30 PM
#5
Re: Cannot connect Access 2003 to VB6
I just changed yours, try this...
VB Code:
cn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"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.
-
Dec 1st, 2006, 11:31 PM
#6
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:
Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:\Usama\db\db97.mdb;User Id=admin;Password=;
-
Dec 1st, 2006, 11:56 PM
#7
Thread Starter
Lively Member
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:
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??
-
Dec 2nd, 2006, 12:00 AM
#8
Re: Cannot connect Access 2003 to VB6
You really should get away from using ODBC unless it is absolutely needed...
-
Dec 2nd, 2006, 12:02 AM
#9
Thread Starter
Lively Member
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|