Microsoft KB Archive/247662: Difference between revisions

From BetaArchive Wiki
(importing KB archive)
 
m (Text replacement - """ to """)
 
Line 61: Line 61:


The white paper uses the following code to illustrate opening a Microsoft Jet database that has user security applied:
The white paper uses the following code to illustrate opening a Microsoft Jet database that has user security applied:
<pre class="codesample">cnn.Provider = &quot;Microsoft.Jet.OLEDB.4.0&quot;
<pre class="codesample">cnn.Provider = "Microsoft.Jet.OLEDB.4.0"
cnn.Properties(&quot;Jet OLEDB:System database&quot;) = &quot;c:\sysdb.mdw&quot;
cnn.Properties("Jet OLEDB:System database") = "c:\sysdb.mdw"
cnn.Open &quot;Data Source=c:\nwind.mdb;User Id=Admin;Password=password;&quot;
cnn.Open "Data Source=c:\nwind.mdb;User Id=Admin;Password=password;"
                 </pre>
                 </pre>
However, you will receive run-time error 3265:
However, you will receive run-time error 3265:
<div class="errormessage">
<div class="errormessage">


&quot;The item cannot be found in the collection corresponding to the requested name or ordinal&quot;
"The item cannot be found in the collection corresponding to the requested name or ordinal"


</div>
</div>
if you try to apply the following code to use the MSDataShape provider:
if you try to apply the following code to use the MSDataShape provider:
<pre class="codesample">cnn.Provider = &quot;MSDataShape&quot;
<pre class="codesample">cnn.Provider = "MSDataShape"
cnn.Properties(&quot;Jet OLEDB:System database&quot;) = &quot;c:\sysdb.mdw&quot;
cnn.Properties("Jet OLEDB:System database") = "c:\sysdb.mdw"
cnn.Open &quot;Data Provider=Microsoft.Jet.OLEDB.4.0;Data Source=c:\nwind.mdb;User Id=Admin;Password=password;&quot;
cnn.Open "Data Provider=Microsoft.Jet.OLEDB.4.0;Data Source=c:\nwind.mdb;User Id=Admin;Password=password;"
                 </pre>
                 </pre>
The error occurs because the &quot;Jet OLEDB: System Database&quot; property is provider-specific. The MSDataShape provider does not expose the property.<br />
The error occurs because the "Jet OLEDB: System Database" property is provider-specific. The MSDataShape provider does not expose the property.<br />
<br />
<br />
To open the secured database correctly, use the following code:
To open the secured database correctly, use the following code:
<pre class="codesample">cnn.Provider = &quot;MSDataShape&quot;
<pre class="codesample">cnn.Provider = "MSDataShape"
cnn.Open &quot;Data Provider=Microsoft.Jet.OLEDB.4.0;Data Source=c:\nwind.mdb;User Id=Admin;Password=password;Jet OLEDB:System Database=c:\sysdb.mdw&quot;
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"
                 </pre>
                 </pre>
<div class="indent">
<div class="indent">
Line 88: Line 88:


</div>
</div>
<pre class="codesample">cnn.Open &quot;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&quot;
<pre class="codesample">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"
                 </pre>
                 </pre>
To open a database secured with a database password, use the following code:
To open a database secured with a database password, use the following code:
<pre class="codesample">cnn.Open &quot;Provider=MSDataShape;Data Provider=Microsoft.Jet.OLEDB.4.0;Data Source=c:\nwind.mdb;Jet OLEDB:Database Password=DBPassword&quot;
<pre class="codesample">cnn.Open "Provider=MSDataShape;Data Provider=Microsoft.Jet.OLEDB.4.0;Data Source=c:\nwind.mdb;Jet OLEDB:Database Password=DBPassword"
                 </pre>
                 </pre>
To open a database secured with both a database password and a user password, use this code:
To open a database secured with both a database password and a user password, use this code:
<pre class="codesample">cnn.Open &quot;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&quot;
<pre class="codesample">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"
                 </pre>
                 </pre>



Latest revision as of 13:50, 21 July 2020

Knowledge Base


How To Access a Secured Jet Database Through the MSDataShape Provider

Article ID: 247662

Article Last Modified on 6/29/2004



APPLIES TO

  • Microsoft ActiveX Data Objects 2.1
  • Microsoft ActiveX Data Objects 2.1 Service Pack 1
  • Microsoft ActiveX Data Objects 2.1 Service Pack 2
  • Microsoft ActiveX Data Objects 2.5
  • Microsoft Visual Basic 5.0 Learning Edition
  • Microsoft Visual Basic 6.0 Learning Edition
  • Microsoft Visual Basic 5.0 Professional Edition
  • Microsoft Visual Basic 6.0 Professional Edition
  • Microsoft Visual Basic 5.0 Enterprise Edition
  • Microsoft Visual Basic 6.0 Enterprise Edition



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"
                

Keywords: kbhowto kbmdacnosweep KB247662