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

i thought that odbc can implement a generic way of connection. So i've
create an OleDbConnection object :

Private theOleDbConnection As OleDbConnection
...
theOleDbConnection = New OleDbConnection
theOleDbConnection.ConnectionString = ??

what kind of connection string should i use (i've tried some without
any result) ? is there's an other way to have a generic connection ??

thanks a lot in advance for your help.

Nicolas H.

Re: Generic OLEDBConnection by Grzegorz

Grzegorz
Mon Nov 15 13:01:08 CST 2004


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


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.

Re: Generic OLEDBConnection by nico

nico
Fri Nov 19 03:00:47 CST 2004

Maybe it's not possible ???

No one have an idea ?

thanks

Nicolas H.



nicolas.hilaire@motorola.com (Nicolas Hilaire) wrote in message news:<1bf7bcf3.0411160151.12f12d14@posting.google.com>...
> "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.

Re: Generic OLEDBConnection by nicolas

nicolas
Fri Nov 19 10:08:42 CST 2004

no one have a solution for this problem ??


nicolas.hilaire@motorola.com (Nicolas Hilaire) wrote in message news:<1bf7bcf3.0411160151.12f12d14@posting.google.com>...
> "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.