Re: ODBC string in ADO.NET
- From: Alex K. <AlexK@xxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Mon, 18 Feb 2008 10:29:02 -0800
"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
- References:
- ODBC string in ADO.NET
- From: Alex K.
- Re: ODBC string in ADO.NET
- From: Nicholas Paldino [.NET/C# MVP]
- ODBC string in ADO.NET
- Prev by Date: Re: Accessing shared network drives prevents standby mode
- Next by Date: SV: Should i use Array, double[][] or double[,]?
- Previous by thread: Re: ODBC string in ADO.NET
- Next by thread: Re: ODBC string in ADO.NET
- Index(es):
Relevant Pages
|
Loading