Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Conditional object dimension
Message
From
18/02/2003 16:16:57
 
 
To
18/02/2003 15:56:31
Rex Mahel
Realm Software, Llc
Ohio, United States
General information
Forum:
ASP.NET
Category:
Other
Miscellaneous
Thread ID:
00754495
Message ID:
00754649
Views:
28
Rex,

I don't think I'd do it this way to begin with ... I'd have two different DataAccess objects, one to get data from Oracle, one from OleDB.

However, to do what you want to do, if you can cast OracleConnection to OleDbConnection (and I'm not sure if you can or not), then you could maybe do something like this (this is untested code, and it's also C# code ... sorry, I don't know VB well enough):
OleDbConnection ConPubs;
if (strProvider == "OracleClient")
{
  OracleConnection o = new OracleConnection(odh);
  ConPubs = o;
}
else
  ConPubs = new OleDbConnection(odh);

ConPubs.Open();
~~Bonnie


>Mike,
>
>Is there a way to do what I am trying to do in my original example? I want to be able to use either the OleDb or Oracle provider.
>
>
>Dim strProvider As String = "OracleClient"
>
>If strProvider = "OracleClient"
>	Dim ConPubs As New OracleConnection(odh)
>Else
>	Dim ConPubs As New OleDbConnection(odh)
>End If
>
>ConPubs.Open()
>
>
>Thanks
>
>Rex
>
>
>>Declare the variable outside the If
>>
>>OracleConnection myConnection;
>>OracleCommand myCommand;
>>if () {
>>}
>>
>>The compiler is probably throwing the error because it can't guarantee that the object is created. It's also possible that the variable no longer exists since it was declared within the scope of the IF. I'm not completely sure if VB.Net behaves this way or not.
>>
>>-Mike
Bonnie Berent DeWitt
NET/C# MVP since 2003

http://geek-goddess-bonnie.blogspot.com
Previous
Reply
Map
View

Click here to load this message in the networking platform