Private Sub Command1_Click()
 Dim cn As ADODB.Connection
 Dim rs As ADODB.Recordset
 Set cn = New ADODB.Connection
 Set rs = New ADODB.Recordset
 On Error GoTo myerror
 cn.Provider = "Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\Main.mdb;Persist Security Info=true;Password=123456789"
 cn.CursorLocation = adUseClient
 cn.Open
 rs.Open "SELECT * FROM BA_Data", cn, adOpenKeyset, adLockOptimistic, 0
 
 MsgBox "Total record in table " & rs.RecordCount
 
 rs.Close
 cn.Close
Exit Sub
myerror:
 MsgBox Err.Number & " - " & Err.Description, vbOKOnly + vbExclamation, "button click: " & Erl
End Sub

Here i m trying to connect a file which is password set
so but it gives Error with certain -2147217843 (80040e4d)
that is MDAC version is not matched as i have Windows 7
with full licensed copy still it is giving error n there is other option i got
on MS site to have compatible version of MDAC for my OS
so can u help me to solve this issue plz ASAP?

It seems that the MS ActiveX DataObjects that you referenced in your application is older than that installed on Win7, IF it was installed correctly. First check your references and make sure that the newest data object (2.8 or higher works fine) is selected. If you can not find it under your references, download the newest MDAC pack and install, then do the reference again.

It seems that the MS ActiveX DataObjects that you referenced in your application is older than that installed on Win7, IF it was installed correctly. First check your references and make sure that the newest data object (2.8 or higher works fine) is selected. If you can not find it under your references, download the newest MDAC pack and install, then do the reference again.

No sir, it is not working yet n i tried for newest version of MDAC 2.8
btw can u let me know which version of MDAC is suitable for Windows 7?

n 1 more thing it may solved by using MDAC newest version bt if my client has older
OS then what do i do?

If you download the newest MDAC and reference this in your application, when you compile the app, the version of mdac that you referenced will be added automatically to your .Cab file. When you install the app onto the users machine, Mdac will install as well, ensuring that the user has the correct version, no matter their OS.

MDAC 2.8 and up will be fine on win 7. I am running 2.8 on XP, Vista AND 7 without problems. That means that we have another problem here...

You will receive an error when trying to install MDAC on win 7 because it is already shipped with win 7. There is also a file called WDAC which is replacing MDAC. You might have a problem with this. see the following link, this might help. Please let me know if this solved your problem.

http://msdn.microsoft.com/en-us/library/ms693114(VS.85).aspx

This link shows you how to troubleeshoot the data access objects on win7.

What version of access? because if *.mdb is either 2k or 97 or earlier, you may need MDAC 2.5 as the jet components were seperated out of the MDAC thereafter... Just a thought...

Good Luck

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.