
February 13th, 2004, 01:00 PM
|
|
Registered User
|
|
Join Date: Feb 2004
Posts: 2
Time spent in forums: < 1 sec
Reputation Power: 0
|
|
|
Invalid Cast Exception
Hi all!
Why I can't convert the type OleDbConnection to IdbConnection
I'm using the sentence:
Ctype(<something of type OleDbConnection>, IdbConnection)
it's generates the error:
[InvalidCastException: Specified cast is not valid.]
If oledbconnection implements idbconnection, I could cast it? or not? Why?
Thanks
(I'm trying to do this cast because I'm using a dataProvider, then i set the data of my provider in the web.config file
I create the provider reading the values of web.config and one of this is the ConnectionType (it is a System.Data.OleDb.OleDbConnection in this case), but for using it in the program I always use the reference to the interface for not rewrite the code if I change the database.
When i'm trying to inizialize the connection I have this sentence
_conn = CType(_provider.ConnectionType, IdbConnection)
|