• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 721
  • Last Modified:

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
1 Solution
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.  
hotshottoolsAuthor Commented:

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

Featured Post

The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now