C
CMaster383
Language: VB.NET (could apply to C#)
Hey,
I am working on a component that will take any of the ADO.Net
connection Classes, OleDb, ODBC, SQL, and Oracle, and return the
appropriate Command Object for that type of connection. I have this
working successfully, but I am running into one flaw. I would like to
use Option Strict on the project, (which I assume will make the code
run faster).
But, in order to achieve this ability to return a Command Object at
runtime, I am forced to return the Object as a System.Object. From
there, I can not run the ExecuteReader method, or any of the other
methods on the object, if the Option Strict is enabled. I have tried
using the GetType method with CType, DirectCast and
'System.ComponentModel.TypeConverter' ConvertTo method with no luck.
My question boils down to this: Is there a way to perform Type
Casting by referencing the objects Type (GetType) and then performing
a type-cast at runtime?
I know this may sounds/seem a bit odd, but I was hoping it would be
possible since all of the Command Objects under .Net are written with
the same Methods (Thanks to microsoft for that). Any information would
be appreciate, Thanks
-Kevin
Hey,
I am working on a component that will take any of the ADO.Net
connection Classes, OleDb, ODBC, SQL, and Oracle, and return the
appropriate Command Object for that type of connection. I have this
working successfully, but I am running into one flaw. I would like to
use Option Strict on the project, (which I assume will make the code
run faster).
But, in order to achieve this ability to return a Command Object at
runtime, I am forced to return the Object as a System.Object. From
there, I can not run the ExecuteReader method, or any of the other
methods on the object, if the Option Strict is enabled. I have tried
using the GetType method with CType, DirectCast and
'System.ComponentModel.TypeConverter' ConvertTo method with no luck.
My question boils down to this: Is there a way to perform Type
Casting by referencing the objects Type (GetType) and then performing
a type-cast at runtime?
I know this may sounds/seem a bit odd, but I was hoping it would be
possible since all of the Command Objects under .Net are written with
the same Methods (Thanks to microsoft for that). Any information would
be appreciate, Thanks
-Kevin