Microsoft KB Archive/818518

= FIX: &quot;Can't Save&quot; Error Occurs When You Try to Save an ADO Recordset to a File =

Article ID: 818518

Article Last Modified on 5/17/2007

-

APPLIES TO


 * Microsoft ActiveX Data Objects 2.7
 * Microsoft Data Access Components 2.8

-





SYMPTOMS
When you try to save an ADO recordset to a file that was created by another user of the system, you may receive the following error message:

Run-time error '-2147286781 (80030103)':

Can't save.

You receive this error message if the application is in a read-only folder, even if the recordset file is in a folder that has write permissions for both users.



CAUSE
When you try to save the recordset to a file that already exists, the recordset object creates a temporary file in the folder of the application. This folder is a read-only folder. Therefore, the second user cannot overwrite the source file.



RESOLUTION
This problem is resolved in Microsoft Data Access Components (MDAC) 2.8. In MDAC 2.8, the ADODB recordset creates the temporary file in the same folder as the destination file that was used to save the recordset.

To download Microsoft Data Access Components (MDAC) 2.8, visit the following Microsoft Web site:

Note Microsoft recommends that you test your application with MDAC 2.8 in a test environment first, to make sure that you are aware of any compatibility issues before you decide to use (or upgrade to) the MDAC 2.8 version.



STATUS
Microsoft has confirmed that this is a bug in the Microsoft products that are listed at the beginning of this article. This bug was corrected in MDAC 2.8.



Steps to Reproduce the Behavior
 Start Microsoft Visual Basic 6.0. On the File menu, click New Project. In the New Project dialog box, click Standard Exe. By default, Form1 is created. On the Project menu, click References. Click Microsoft ActiveX Data Objects 2.7 Library, and then click OK. Add two Command buttons to the form.  Right-click Form1, click View Code, and then add the following code: Option Explicit

Private Sub Command1_Click Dim cn As New Connection Dim rs As New Recordset

On Error GoTo ErrHandler cn.ConnectionString = &quot;Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=Northwind;Data Source=YourSQLServer&quot; cn.Open ' Open the RecordSet rs.Open &quot;SELECT * FROM CUSTOMERS&quot;, cn, adOpenDynamic, adLockPessimistic ' Persist the RecordSet rs.Save &quot;C:\Documents and Settings\NonAdminUserName\My Documents\Customer.dat&quot; Exit Sub ErrHandler: MsgBox &quot;Error : &quot; & Err.Description End Sub

Private Sub Command2_Click Dim rs As New ADODB.Recordset On Error GoTo ErrHandler: ' Read the Persisted RecordSet rs.Open &quot;C:\Documents and Settings\NonAdminUserName\My Documents\Customer.dat&quot; ' Save the RecordSet rs.Save &quot;C:\Documents and Settings\NonAdminUserName\My Documents\Customer.dat&quot; Exit Sub

ErrHandler: MsgBox &quot;Error Number: &quot; & Err.Number MsgBox &quot;Error Description: &quot; & Err.Description End Sub

Private Sub Form_Load Command1.Caption = &quot;Persist RecordSet&quot; Command2.Caption = &quot;Reload Data&quot; End Sub </li> Replace &quot;YourSQLServer&quot; in the connection string with the name of your SQL Server.</li> Save the project in the C:\Program Files\Test folder.</li> On the Run menu, click Start.</li> Click Persist RecordSet, and then click Reload Data. No error occurs.</li> Log on to the computer as a non-administrator user (by default, non administrators do not have write access to the C:\Program Files\ folder).</li> Run the project again. You receive the error message that is described in the &quot;Symptoms&quot; section.</li></ol>

<div class="references_section">