Re: Generic OLEDBConnection by nicolas
nicolas
Tue Nov 16 03:51:20 CST 2004
"Grzegorz Danowski" <gdn@usuntopoczta.onet.pl> wrote in message news:<cnauds$63m$1@inews.gazeta.pl>...
> Uzytkownik "Nicolas Hilaire" <nicolas.hilaire@motorola.com> napisal w
> wiadomosci news:1bf7bcf3.0411150835.9f208d2@posting.google.com...
> > Hi all,
> >
> > i need to make a connection to a database, but i can't know in advance
> > what kind of database it will be. That can be an oracle database,
> > access database, sql server database, and so on ...
> >
> > My user will create an ODBC DSN and will set it's name in my
> > application.
> >
> > Then i will have only this information : the DSN NAME
> >
>
> Why not Odbc provider and OdbcConnection, for example:
> OdbcConnection con = new OdbcConnection("dsn=MyDsn;")
>
> Regards,
> Grzegorz
yes, why not ? but i have this exception :
ERROR [IM006] [Microsoft][ODBC Driver Manager] Driver's
SQLSetConnectAttr failed ERROR [01000] [Microsoft][ODBC Driver
Manager] The driver doesn't support the version of ODBC behavior that
the application requested (see SQLSetEnvAttr). ERROR [01S00]
[Microsoft][ODBC driver for Oracle]Invalid connection string attribute
with this code :
Dim con As New Odbc.OdbcConnection("dsn=myDsn;User
Id=myUser;Password=myPwd;"
con.Open() 'exception comes on this line
but i can connect to my database by this way, but you've understood
that it's not the way i want :
dim theOleDbConnection as New
OleDbConnection("Provider=oraOLEDB.Oracle;SERVER=myServer;Data Source
=myDsn;User Id=myUser;Password=myPwd;")
theOleDbConnection.Open() ' Working
Thanks to help me to have a generic connection independtly to the
database
Regards
Nicolas H.