SQL Server TechCenter > SQL Server Forums > SQL Server Integration Services > Unable to cast COM object of type 'System.__ComObject' to class type 'System.Data.Oledb.OledbConnection'
Ask a questionAsk a question
 

AnswerUnable to cast COM object of type 'System.__ComObject' to class type 'System.Data.Oledb.OledbConnection'

  • Thursday, August 07, 2008 9:54 AMTony.alex Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     

     

    Hi ,

     

    i am getting  the following error

     

    Unable to cast COM object of type 'System.__ComObject' to class type 'System.Data.Oledb.OledbConnection'. Instances of types that represent COM components cannot be cast to types that do not represent COM components; however they can be cast to interfaces as long as the underlying COM component supports QueryInterface calls for the IID of the interface.

     

     

    Please help

Answers

  • Friday, August 08, 2008 7:15 AMDarren Green SQLISMVP, ModeratorUsers MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Answer

    Correct, if you want to use the connection object in a script, it must be ADO.NET, not OLE-DB, so that means two for you. The alternative is what the other posted attempted, using the connection string from an OLE-DB connection, to initialise a .NET connection object, but with the limitation of no password. if you use only integrated security it is a poissible solution.

All Replies