Re: ODBC string in ADO.NET





"Nicholas Paldino [.NET/C# MVP]" wrote:

Alex,

Why should it work? You are using an Ole DB connection string with the
ODBC provider classes. If you want to use the same connection string that
you use with ADO then you should be using the classes in the System.OleDb
namespace.

....and that's exactly what I did! When trying for the first time, I used
OledbConnection and got the error:

The .Net Framework Data Provider for ELEDB (System.Data.OleDb) does not
support the Microsoft OLE DB Provider for ODBC Drivers (MSDASQL). Use the
..Net Framework Data Provider for ODBC (System.Data.Odbc).

after getting this error I started to use OdbcConnection from
System.Data.Odbc, and I got the posted error. BTW, the ODBC connection string
was created using Microsoft Data Link Properties wizard. Same string works
fine in ADO, but it does not work in .Net Odbc. As I pointed out in my post,
a quotation mark that closes Extended Properties substring is what is causing
the problem - which is very strange!

I always used to generate ODBC strings using a certain set of rules and
until now it worked pretty well. Now when I am migrating my VB6 + ADO 2.6
application to .Net 2.0 I have to double check (and most likely change) all
my ODBC connection strings! And I cannot use Data Link wizard dll anymore,
because connection string produced may not work.



--
- Nicholas Paldino [.NET/C# MVP]
- mvp@xxxxxxxxxxxxxxxxxxxxxxxxxxx

"Alex K." <AlexK@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:55AE63D2-EDC8-4E08-A96F-36B716E33253@xxxxxxxxxxxxxxxx
Hi all

I just noticed that OdbcConnection (.NET 2.0 SP1) does not accept a
connection string that works file in ADO 2.8. For example, following
string
gives me an error "Login failed ... cannot open database
"AdventureWorks"":

Provider=MSDASQL.1;Password=...;Persist Security Info=True;User
ID=...;Extended Properties="Description=Adventure;DRIVER=SQL
Server;SERVER=...\sqlexpress;UID=...;PWD=...;DATABASE=AdventureWorks"

I figured out that last quotation mark causes the problem: if I remove it,
it works fine - but then it does not work in ADO 2.8!

Can anybody confirm this is a known problem with .NET 2.0 ODBC?
(BTW I tried both drivers SQL Server and SQL Native Client with the same
results)

Thank you
Alex



.



Relevant Pages

  • Re: How to load data in ListBox using one command from ADODB Recor
    ... Simply use an DSN-less connection string as the ODBC Connection String. ... >> Is there something unique about how you use the ADODB recordset? ... >>> I am using ADODB recordset and has SQL server database. ...
    (microsoft.public.access.gettingstarted)
  • Re: Connection String
    ... does someone have some sample code that creates a ... > connection string (i.e. reads the ODBC so I can set the provider, ... Since you are using SQL Server, use the OLEDB provider for it and not ... ODBC has been deprecated. ...
    (borland.public.delphi.database.ado)
  • Re: ODBC connection strings - "ODBC;" prefix?
    ... As you can see, if there is "ODBC;" in the connection string, ... Microsoft Online Community Support ... where an initial response from the community or a Microsoft Support ...
    (microsoft.public.vc.database)
  • RE: SQL Server 2005 Express connection error?
    ... What provider is specified in MyProjectConfiguration.DbProviderName? ... getting an "Unable to find the requested .Net Framework Data Provider. ... //Obtain the database connection string ...
    (microsoft.public.dotnet.framework.adonet)
  • Re: ODBC connection strings - "ODBC;" prefix?
    ... MFC is adding the "ODBC;" in the call I referenced in my prior reply. ... As you can see, if there is "ODBC;" in the connection string, ... Microsoft Online Community Support ...
    (microsoft.public.vc.database)

Loading