Microsoft KB Archive/296853

= PRB: Run-Time Error -2147286789 When You Use UDL File to Open ADO Connection =

Article ID: 296853

Article Last Modified on 6/29/2004

-

APPLIES TO


 * Microsoft OLE DB 2.0
 * Microsoft OLE DB 2.1
 * Microsoft OLE DB 2.5
 * Microsoft OLE DB 2.6
 * Microsoft ActiveX Data Objects 2.0
 * 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 ActiveX Data Objects 2.6
 * Microsoft ActiveX Data Objects 2.7
 * Microsoft Visual Basic 5.0 Enterprise Edition
 * Microsoft Visual Basic 6.0 Enterprise Edition
 * Microsoft Visual Basic 6.0 Enterprise Edition Service Pack 3
 * Microsoft Visual Basic 6.0 Enterprise Edition Service Pack 4
 * Microsoft Visual Basic 6.0 Enterprise Edition Service Pack 5
 * Microsoft Visual Basic 5.0 Professional Edition
 * Microsoft Visual Basic 6.0 Professional Edition

-



This article was previously published under Q296853



SYMPTOMS
If you try to open an ADO connection using a data link file (which is commonly referred to as a universal data link file, or UDL file), you may receive the following error message:

Run-time error -2147286789(800300fb): The File is not a valid compound file



CAUSE
There are two causes for this behavior:
 * The database connection information in the UDL file is in an invalid format.
 * The UDL file may be corrupted.



RESOLUTION
To resolve this problem, use one of the following methods:
 * In the OLE DB Data Link Properties dialog box, re-create the UDL file.
 * In Notepad, open the UDL file manually to verify its format and make any required changes. For additional information, see the &quot;More Information&quot; section.



MORE INFORMATION
Data link files provide a convenient way to create and verify an ADO connection string that is used to connect to an OLE DB data source. The connection string information is persisted in a specific format to a data link file with the .udl extension. The data link file is a unicode text file that you can edit using a unicode text editor such as Notepad. For more information on how to create UDL files using the OLE DB Data Link Properties dialog box, see the &quot;References&quot; section.

A UDL file is comprised of three lines of text. For example:

[oledb] Provider=Microsoft.Jet.OLEDB.4.0;Data Source=d:\testdb.mdb
 * Everything after this line is an OLE DB initstring

The first two lines (the OLE DB section declaration and the following comment line) are constant and must be present in all UDL files. If you delete or modify either of these lines, you receive the above-mentioned error message when you try to use the UDL file to connect to a data source.

The third line is the ADO connection string that is used to open a connection to the data source. This line changes when different UDLs are created to connect to different data sources or when a different set of options is specified to connect to the same data source.

Steps to Reproduce Behavior
This sample uses an ADO connection string to connect to the SQL Server PUBS sample database. You can modify the connection string to point to one of your SQL Server databases, or you can specify a string that connects to an alternate data source.  In Notepad, create a new file named Test.udl, and paste the following text.

Note Make sure that  has the appropriate permissions to perform the operation on the database.

[oledb] Provider=SQLOLEDB;Data Source=SQLServer;Initial Catalog=pubs;User Id=;Password=
 * Everything after this line is an OLE DB initstring

 Modify the connection string parameters as necessary, and save Test.udl. Create a new Standard EXE project in Visual Basic. Form1 is created by default. On the Project menu, click Reference, and then click Microsoft ActiveX Data Objects 2.x Library.</li> Add a CommandButton control to Form1.</li>  Copy and paste the following code in the Click event procedure of the Command button: Dim cn As ADODB.Connection Set cn = New ADODB.Connection cn.Open &quot;File Name=c:\Test.udl&quot; MsgBox &quot;Connection opened !&quot; cn.Close Set cn = Nothing </li> Modify the path to Test.udl in the cn.Open statement as necessary.</li> Save the project. Press the F5 key to run the project.</li> When Form1 is displayed, click Command1 to open an ADO connection using Test.udl. If you specified the correct connection string attributes in step 2, a &quot;Connection Opened !&quot; dialog box appears. This indicates that the connection to the data source is successfully established.</li> Stop running the project.</li> In Notepad, open Test.udl. On the second line, remove the space between the semicolon (&quot;;&quot;) and &quot;Everything&quot;, and save the changes.</li> Press F5 to run the Visual Basic project again.</li> When Form1 is displayed, click Command1. You receive the above-mentioned error message.</li></ol>

<div class="references_section">