FIX: Recordset.Open Fails When DSN Value Is Not Prefaced with "DSN=" in Connection String (293387)



The information in this article applies to:

  • ActiveX Data Objects (ADO) 2.6

This article was previously published under Q293387

SYMPTOMS

When the data source name (DSN) is not prefaced with "DSN=" in Microsoft Data Access Components (MDAC) or ADO version 2.6, the Recordset.Open <SQL Statement>, <DSN> method returns the following error message:
Data source name not found and no default driver specified
This behavior does not occur if an ADODB.Connection object is used.

RESOLUTION

To resolve this problem, obtain the latest service pack for Microsoft Data Access Components 2.6. For additional information, click the following article number to view the article in the Microsoft Knowledge Base:

300635 INFO: How to Obtain the Latest MDAC 2.6 Service Pack

There are two ways to work around this problem:
  • Add "DSN=" to the connection string when it is intended to be used with an ADODB.Recordset.Open call. For example:
    	Dim objRS as New ADODB.Recordset
    		objRS.Open "SELECT CustomerID, CompanyName FROM CUSTOMERS", _
         			"DSN=NorthwindDSN"
    		'Do Recordset work here.
    		objRS.Close
    		Set objRS = Nothing
    					
  • Specify the appropriate OLE DB Provider and Data Source in your connection string as follows:
    	Dim objRS as New ADODB.Recordset
    		objRS.Open "SELECT CustomerID, CompanyName FROM CUSTOMERS", _
    		     "Provider=Microsoft.Jet.OLEDB.4.0;"
         		     "Data Source=c:\path to file\Nwind.mdb"
    		'Do Recordset work here.
    		objRS.Close
    		Set objRS = Nothing
    					

STATUS

Microsoft has confirmed that this is a problem in the Microsoft products that are listed at the beginning of this article. This problem was first corrected in Microsoft Data Access Components 2.6 Service Pack 2 and MDAC 2.7.

Modification Type:MajorLast Reviewed:5/8/2002
Keywords:kbbug kbDSupport kbmdac260sp2fix KB293387 kbAudDeveloper