Unrecognized Database Format

gsrajan

Registered User.
Local time
Today, 08:25
Joined
Apr 22, 2014
Messages
227
Please let me know what is wrong in this; I am getting the error " Unrecognized Database Format Error.

Thanks for your help.

Sub ShowUserConnected()
Dim cn As New ADODB.Connection
Dim cn2 As New ADODB.Connection
Dim rs As New ADODB.Recordset
Dim i, j As Long
cn.Provider = "Microsoft.Jet.OLEDB.4.0"
cn.Open "Data Source=C:\Users\Philip.Daniel\Documents\Benefits.accdb"
cn2.Open "Provider=Microsoft.Jet.OLEDB.4.0;" _
& "Data Source=C:\Users\Philip.Daniel\Documents\Benefits.accdb"
' The user roster is exposed as a provider-specific schema rowset
' in the Jet 4 OLE DB provider. You have to use a GUID to
' reference the schema, as provider-specific schemas are not
' listed in ADO's type library for schema rowsets
Set rs = cn.OpenSchema(adSchemaProviderSpecific, _
, "{947bb102-5d43-11d1-bdbf-00c04fb92675}")
'Output the list of all users in the current database.
Debug.Print rs.Fields(0).Name, "", rs.Fields(1).Name, _
"", rs.Fields(2).Name, rs.Fields(3).Name
While Not rs.EOF
Debug.Print rs.Fields(0), rs.Fields(1), _
rs.Fields(2), rs.Fields(3)
rs.MoveNext
Wend

End Sub
 
Thank you. Somehow I got the space while pasting the code. I tried again - making sure there is no space, but getting the same error.

Thanks for helping.
 
In which code line do you get the error?
Are you able to open the database directly?
I don't like the dot's in directory names, (... Philip.Daniel ...)!
 
1. This is highlighted:

cn2.Open "Provider=Microsoft.Jet.OLEDB.4.0;" _
& "Data Source=C:\Users\Philip.Daniel\Documents\Benefits.accdb"

2. Yes, I am able to open the database directly

3. I copied the database into My Documents and also to the desktop and tried to avoid the directly name ( Philip.Daniel). Still getting the same error.

Thanks.
 
C:\Users\[Philip.Daniel]\Documents\Benefits.a ccdb "

Try adding square brackets around anything that incorrectly has a period.

Add a space after the opening " and before the closing "

If no joy then delete everything. Then add one thing at a time until you get it to error.
 

Users who are viewing this thread

Back
Top Bottom