Way back in the old ASP days, it was possible to open a Database connection
by providing only the name of the ODBC DSN that I'd created earlier. I didn't
need to indicate which driver, whether the connection was to SqlServer or
something else, etc. It looked like:

Conn = Server.CreateObject("ADODB.Connection")
Conn.Open "MyNamedDSN"

In C#.Net, I'm trying to figure out what connection string I provide when I do
Conn = new OleDbConnection(ConnString);

if I want to connect via an ODBC DSN instead of specifying the details in
the ConnectionString itself. Can you help with this?

Thanks.

Alex

Re: Accessing ODBC DSNs by Shawn

Shawn
Wed Aug 23 18:00:11 CDT 2006

Hello Alex,

DSN's only work with ODBC (since they aren't OLEDB). So change your provider
to OdbcProvider and use your old connection string and it will work:

Conn = new OdbcConnection(ConnString)


Thanks,
Shawn Wildermuth
Speaker, Author and C# MVP
http://adoguy.com

> Way back in the old ASP days, it was possible to open a Database
> connection by providing only the name of the ODBC DSN that I'd created
> earlier. I didn't need to indicate which driver, whether the
> connection was to SqlServer or something else, etc. It looked like:
>
> Conn = Server.CreateObject("ADODB.Connection")
> Conn.Open "MyNamedDSN"
> In C#.Net, I'm trying to figure out what connection string I provide
> when I do
> Conn = new OleDbConnection(ConnString);
> if I want to connect via an ODBC DSN instead of specifying the details
> in the ConnectionString itself. Can you help with this?
>
> Thanks.
>
> Alex
>