How To Access a Secured Jet Database Through the MSDataShape Provider (247662)



The information in this article applies to:

  • ActiveX Data Objects (ADO) 2.1
  • ActiveX Data Objects (ADO) 2.1 SP1
  • ActiveX Data Objects (ADO) 2.1 SP2
  • ActiveX Data Objects (ADO) 2.5
  • Microsoft Visual Basic Learning Edition for Windows 5.0
  • Microsoft Visual Basic Learning Edition for Windows 6.0
  • Microsoft Visual Basic Professional Edition for Windows 5.0
  • Microsoft Visual Basic Professional Edition for Windows 6.0
  • Microsoft Visual Basic Enterprise Edition for Windows 5.0
  • Microsoft Visual Basic Enterprise Edition for Windows 6.0

This article was previously published under Q247662

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"
				

Modification Type:MinorLast Reviewed:6/29/2004
Keywords:kbhowto kbMDACNoSweep KB247662 kbAudDeveloper