Microsoft Knowledge Base Email Alertz

(296853) - 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...

Search KbAlertz

Advanced Search

Receive Microsoft Knowledge Base articles by E-Mail?

Every night we scan the Microsoft Knowledge Base. If technologies you're interested in are updated, we'll send you an e-mail. You only get one e-mail a day, and only when new articles are added.

Click here to create a
FREE account
Already have an account?
[Click here to Login]











Microsoft Knowledge Base Article

This article contents is Microsoft Copyrighted material.
©2005-©2007 Microsoft Corporation. All rights reserved. Terms of Use | Trademarks

Article ID: 296853 - Last Review: June 29, 2004 - Revision: 4.1

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

This article was previously published under Q296853

On This Page

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 "More Information" 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 "References" section.

A UDL file is comprised of three lines of text. For example:
[oledb]
; Everything after this line is an OLE DB initstring
Provider=Microsoft.Jet.OLEDB.4.0;Data Source=d:\testdb.mdb
					
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.
  1. In Notepad, create a new file named Test.udl, and paste the following text.

    Note Make sure that <UID> has the appropriate permissions to perform the operation on the database.
    [oledb]
    ; Everything after this line is an OLE DB initstring
    Provider=SQLOLEDB;Data Source=SQLServer;Initial Catalog=pubs;User Id=<UID>;Password=<strong password>
    						
  2. Modify the connection string parameters as necessary, and save Test.udl.
  3. Create a new Standard EXE project in Visual Basic. Form1 is created by default.
  4. On the Project menu, click Reference, and then click Microsoft ActiveX Data Objects 2.x Library.
  5. Add a CommandButton control to Form1.
  6. 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 "File Name=c:\Test.udl"
     MsgBox "Connection opened !"
     cn.Close
     Set cn = Nothing
    					
  7. Modify the path to Test.udl in the cn.Open statement as necessary.
  8. Save the project. Press the F5 key to run the project.
  9. 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 "Connection Opened !" dialog box appears. This indicates that the connection to the data source is successfully established.
  10. Stop running the project.
  11. In Notepad, open Test.udl. On the second line, remove the space between the semicolon (";") and "Everything", and save the changes.
  12. Press F5 to run the Visual Basic project again.
  13. When Form1 is displayed, click Command1. You receive the above-mentioned error message.

REFERENCES

For additional information, click the article numbers below to view the articles in the Microsoft Knowledge Base:
189680  (http://kbalertz.com/Feedback.aspx?kbNumber=189680/EN-US/ ) HOWTO: Use Data Link Files with ADO
286189  (http://kbalertz.com/Feedback.aspx?kbNumber=286189/EN-US/ ) HOWTO: Invoke OLE DB Data Link Properties Dialog Box in Visual Basic Code
283245  (http://kbalertz.com/Feedback.aspx?kbNumber=283245/EN-US/ ) HOWTO: Persist Data Links Programmatically

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 Enterprise Edition for Windows 6.0
  • 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
Keywords: 
kbprb KB296853
       

Community Feedback System

Very often, it takes hours to solve a problem. Very often, you've looked high and low, and have tried a lot of solutions. When you finally found it, chances are, it was because someone else helped you. Here's your chance to give back. Use our community feedback tool to let others know what worked for you and what didn't.

Please also understand that the community feedback system is not warranted to be correct, it's simply a system that we've built to let people try and help each other. If something in a feedback response doesn't make sense to you, or you're not comfortable making changes that the feedback talks about (like registry edits), please consult a professional.

Thank you for using kbAlertz.com Feedback System.

-- Scott Cate