Hi there,
this is what i'm trying to achieve, i have separate identical classes for
SqlClient, OracleClient, Odbc and OleDb, what i want is to create a Wrapper
class that calls any of these 4 based on the user connection.... so what i
had in mind was something like this:
Application starts and prompts user to create a database connection.
User selects "Oracle" connect, so i set a parameter in the generic wrapper,
"activeConnection" = oracle (or from enum selection).
Now from here on, i should only have to access the generic wrapper,
eg..something like:
//assuming this is all i need to point the wrapper in the right direction//
GenericDataWrapper x = new GenericDataWrapper();
x.activeConnection = ConnectType.Oracle
x.Connect("connectionstring goes here"...); - we stop here..
So, at the point where x references a procedure, i want the generic wrapper
to go to MyClass.Data.OracleClient.Connect(), if you get the drift of where
i'm coming from.
Does this mean that in the generic class i have to use a switch statement
for every function call, so i point it internally to the right class or is
there a cleaner way with less code here?
any help appreciated.
thanks,
Paul 6 3180
Hi,
"Milsnips" <mi******@hotmail.comwrote in message
news:OC**************@TK2MSFTNGP02.phx.gbl...
Hi there,
this is what i'm trying to achieve, i have separate identical classes for
SqlClient, OracleClient, Odbc and OleDb, what i want is to create a
Wrapper class that calls any of these 4 based on the user connection....
so what i had in mind was something like this:
Have you take a look at the Abstract Factory pattern? http://en.wikipedia.org/wiki/Abstract_factory_pattern
I thnk it will help you
--
Ignacio Machin
machin AT laceupsolutions com
Hi Ignacio,
no i havent seen this. i'll have a look now and hope its what i'm after.
Paul
thanks,
"Ignacio Machin ( .NET/ C# MVP )" <machin TA laceupsolutions.comwrote in
message news:Ok*************@TK2MSFTNGP06.phx.gbl...
Hi,
"Milsnips" <mi******@hotmail.comwrote in message
news:OC**************@TK2MSFTNGP02.phx.gbl...
>Hi there,
this is what i'm trying to achieve, i have separate identical classes for SqlClient, OracleClient, Odbc and OleDb, what i want is to create a Wrapper class that calls any of these 4 based on the user connection.... so what i had in mind was something like this:
Have you take a look at the Abstract Factory pattern?
http://en.wikipedia.org/wiki/Abstract_factory_pattern
I thnk it will help you
--
Ignacio Machin
machin AT laceupsolutions com
In addition to the above, if you poke around System.Data, you'll notice
that System.Data.OleDB.OleDBConnection, odbc.odbcConnection,
SqlClient.SqlConnection all derive from the same base type
IdbConnection. Command, recordset, adapter, everything each derive from
a general interface. This is useful as the actual data is agnostic,
DataSet lives in System.Data, so any IdbConnection, etc can be used to
obtain a DataSet.
We don't use oracle here, so I can't confirm their library conforms,
but it would be a bit bloody minded of them not to.
Milsnips wrote:
Hi Ignacio,
no i havent seen this. i'll have a look now and hope its what i'm after.
Paul
thanks,
"Ignacio Machin ( .NET/ C# MVP )" <machin TA laceupsolutions.comwrote in
message news:Ok*************@TK2MSFTNGP06.phx.gbl...
Hi,
"Milsnips" <mi******@hotmail.comwrote in message
news:OC**************@TK2MSFTNGP02.phx.gbl...
Hi there,
this is what i'm trying to achieve, i have separate identical classes for
SqlClient, OracleClient, Odbc and OleDb, what i want is to create a
Wrapper class that calls any of these 4 based on the user connection....
so what i had in mind was something like this:
Have you take a look at the Abstract Factory pattern? http://en.wikipedia.org/wiki/Abstract_factory_pattern
I thnk it will help you
--
Ignacio Machin
machin AT laceupsolutions com
Thanks also for your reply. I looked at the abstract factory pattern in the
first reply and its pretty heavy stuff for me, although i think i can half
understand it, but much to go.
This idbConnection seems like what i'm after, i'll see how far i can get
with this.
thanks,
Paul
"DeveloperX" <nn*****@operamail.comwrote in message
news:11*********************@o58g2000hsb.googlegro ups.com...
In addition to the above, if you poke around System.Data, you'll notice
that System.Data.OleDB.OleDBConnection, odbc.odbcConnection,
SqlClient.SqlConnection all derive from the same base type
IdbConnection. Command, recordset, adapter, everything each derive from
a general interface. This is useful as the actual data is agnostic,
DataSet lives in System.Data, so any IdbConnection, etc can be used to
obtain a DataSet.
We don't use oracle here, so I can't confirm their library conforms,
but it would be a bit bloody minded of them not to.
Milsnips wrote:
>Hi Ignacio,
no i havent seen this. i'll have a look now and hope its what i'm after. Paul thanks,
"Ignacio Machin ( .NET/ C# MVP )" <machin TA laceupsolutions.comwrote in message news:Ok*************@TK2MSFTNGP06.phx.gbl...
Hi,
"Milsnips" <mi******@hotmail.comwrote in message
news:OC**************@TK2MSFTNGP02.phx.gbl... Hi there,
this is what i'm trying to achieve, i have separate identical classes for SqlClient, OracleClient, Odbc and OleDb, what i want is to create a Wrapper class that calls any of these 4 based on the user connection.... so what i had in mind was something like this:
Have you take a look at the Abstract Factory pattern?
http://en.wikipedia.org/wiki/Abstract_factory_pattern
I thnk it will help you
--
Ignacio Machin
machin AT laceupsolutions com
EnterpriseLibrary (Data) has already done most of this.
Don't reinvent the wheel.
You can also read this post: http://groups.google.com/group/micro...cbbe0ed0c4519a
or http://groups.google.com/groups/sear...y+&qt_s=Search
find ...
MyDatabaseFactory
"Milsnips" <mi******@hotmail.comwrote in message
news:OC**************@TK2MSFTNGP02.phx.gbl...
Hi there,
this is what i'm trying to achieve, i have separate identical classes for
SqlClient, OracleClient, Odbc and OleDb, what i want is to create a
Wrapper
class that calls any of these 4 based on the user connection.... so what i
had in mind was something like this:
Application starts and prompts user to create a database connection.
User selects "Oracle" connect, so i set a parameter in the generic
wrapper,
"activeConnection" = oracle (or from enum selection).
Now from here on, i should only have to access the generic wrapper,
eg..something like:
//assuming this is all i need to point the wrapper in the right
direction//
GenericDataWrapper x = new GenericDataWrapper();
x.activeConnection = ConnectType.Oracle
x.Connect("connectionstring goes here"...); - we stop here..
So, at the point where x references a procedure, i want the generic
wrapper
to go to MyClass.Data.OracleClient.Connect(), if you get the drift of
where
i'm coming from.
Does this mean that in the generic class i have to use a switch statement
for every function call, so i point it internally to the right class or is
there a cleaner way with less code here?
any help appreciated.
thanks,
Paul
Hi Paul,
you can use the DbProviderFactory and DbPrvoviderFactories classes.
Christof
"Milsnips" <mi******@hotmail.comschrieb im Newsbeitrag
news:OC**************@TK2MSFTNGP02.phx.gbl...
Hi there,
this is what i'm trying to achieve, i have separate identical classes for
SqlClient, OracleClient, Odbc and OleDb, what i want is to create a
Wrapper class that calls any of these 4 based on the user connection....
so what i had in mind was something like this:
Application starts and prompts user to create a database connection.
User selects "Oracle" connect, so i set a parameter in the generic
wrapper, "activeConnection" = oracle (or from enum selection).
Now from here on, i should only have to access the generic wrapper,
eg..something like:
//assuming this is all i need to point the wrapper in the right
direction//
GenericDataWrapper x = new GenericDataWrapper();
x.activeConnection = ConnectType.Oracle
x.Connect("connectionstring goes here"...); - we stop here..
So, at the point where x references a procedure, i want the generic
wrapper to go to MyClass.Data.OracleClient.Connect(), if you get the drift
of where i'm coming from.
Does this mean that in the generic class i have to use a switch statement
for every function call, so i point it internally to the right class or is
there a cleaner way with less code here?
any help appreciated.
thanks,
Paul This discussion thread is closed Replies have been disabled for this discussion. Similar topics
16 posts
views
Thread by D Witherspoon |
last post: by
|
6 posts
views
Thread by Robin |
last post: by
|
23 posts
views
Thread by mark.moore |
last post: by
|
351 posts
views
Thread by CBFalconer |
last post: by
|
3 posts
views
Thread by markww |
last post: by
|
9 posts
views
Thread by Steve Richter |
last post: by
|
10 posts
views
Thread by phancey |
last post: by
|
11 posts
views
Thread by Bob Altman |
last post: by
|
11 posts
views
Thread by Rafe |
last post: by
| | | | | | | | | | |