HOWTO: Access a Secured Jet Database Through the MSDataShape Provider
ID: Q247662
|
The information in this article applies to:
-
ActiveX Data Objects (ADO), versions 2.1, 2.1 SP1, 2.1 SP2, 2.5
-
Microsoft Visual Basic Learning, Professional, and Enterprise Editions for Windows, versions 5.0, 6.0
SUMMARY
The Migrating from DAO to ADO white paper discusses how to open a secured Jet database through ActiveX Data Objects (ADO). However, the method illustrated cannot be used when opening the database through the MSDataShape provider.
MORE INFORMATION
The white paper uses the following code to illustrate opening a Microsoft Jet database that has user security applied:
cnn.Provider = "Microsoft.Jet.OLEDB.4.0"
cnn.Properties("Jet OLEDB:System database") = "c:\sysdb.mdw"
cnn.Open "Data Source=c:\nwind.mdb;User Id=Admin;Password=password;"
However, you will receive run-time error 3265:
"The item cannot be found in the collection corresponding to the requested name or ordinal"
if you try to apply the following code to use the MSDataShape provider:
cnn.Provider = "MSDataShape"
cnn.Properties("Jet OLEDB:System database") = "c:\sysdb.mdw"
cnn.Open "Data Provider=Microsoft.Jet.OLEDB.4.0;Data Source=c:\nwind.mdb;User Id=Admin;Password=password;"
The error occurs because the "Jet OLEDB: System Database" property is provider-specific. The MSDataShape provider does not expose the property.
To open the secured database correctly, use the following code:
cnn.Provider = "MSDataShape"
cnn.Open "Data Provider=Microsoft.Jet.OLEDB.4.0;Data Source=c:\nwind.mdb;User Id=Admin;Password=password;Jet OLEDB:System Database=c:\sysdb.mdw"
-or-
cnn.Open "Provider=MSDataShape;Data Provider=Microsoft.Jet.OLEDB.4.0;Data Source=c:\nwind.mdb;User Id=Admin;Password=password;Jet OLEDB:System Database=c:\sysdb.mdw"
To open a database secured with a database password, use the following code:
cnn.Open "Provider=MSDataShape;Data Provider=Microsoft.Jet.OLEDB.4.0;Data Source=c:\nwind.mdb;Jet OLEDB:Database Password=DBPassword"
To open a database secured with both a database password and a user password, use this code:
cnn.Open "Provider=MSDataShape;Data Provider=Microsoft.Jet.OLEDB.4.0;Data Source=c:\nwind.mdb;User Id=Admin;Password=password;Jet OLEDB:System Database=c:\sysdb.mdw;Jet OLEDB:Database Password=DBPassword"
REFERENCES
SHAPE
Additional query words:
Keywords : kbADO kbOLEDB kbGrpVBDB kbDSupport
Version : WINDOWS:2.1,2.1 SP1,2.1 SP2,2.5,5.0,6.0
Platform : WINDOWS
Issue type : kbhowto