.NET Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsProgramming.NET Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old February 13th, 2004, 01:00 PM
cloti cloti is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Feb 2004
Posts: 2 cloti User rank is Just a Lowly Private (1 - 20 Reputation Level) 
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)

Reply With Quote
  #2  
Old February 23rd, 2004, 07:45 PM
Janjan Janjan is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Feb 2004
Posts: 1 Janjan User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
I dont know if this is correct but you can try it.

CType(_provider.ConnectionType, (OleDbConnection) IdbConnection)

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgramming.NET Development > Invalid Cast Exception


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway
Stay green...Green IT