We help IT Professionals succeed at work.

Using a file DSN with an OleDbConnection

I'm looking for a connection string for a file DSN to be used from an OleDbConnection

I have no problem in setting up the connection string for UDL files or connecting to CSV, XLS or MDB but I'm having a problem with DSN.

The DSN will be built by the user so I'll only know the name of the DSN file and not what database they are connecting to.

If I just put in ==> FILEDSN=c:\myData.dsn; to the connection string I get an error saying that it requires a Provider.

I'm using VS 2005 coding in VB for .NET Framework 2.0
Watch Question

Software Developer
DSNs are used by ODBC, so you'd need to use an OdbcConnection.  I'm VB6, you could specify "DSN=" for ADO and it just used the OLEDB - ODBC bridge but with .NET, Microsoft split ODBC and OLEDB into two interfaces (OleDbConnection and OdbcConnection).  
The reason for the error is because OLEDB requires a "Provider=" key pair to work correctly so ADO.NET knows which OLEDB provider to use.  



I'll give that a shot later today (It sounds like it will)

Explore More ContentExplore courses, solutions, and other research materials related to this topic.