Topic
4 replies Latest Post - ‏2012-09-17T14:42:53Z by WKBB_Pavel_Malokhatko
WKBB_Pavel_Malokhatko
3 Posts
ACCEPTED ANSWER

Pinned topic Exception when get DataSourceInformation from ADO.NET OLE DB provider

‏2012-09-10T16:13:38Z |
Hello!

I work with Informix 11.70 at Windows 7 x86. In attempt to receive DataSourceInformation through ADO.NET OLE DB provider I receive System.InvalidCastException exception.

Code on C#:


OleDbConnection connection = 

new OleDbConnection(); connection.ConnectionString = 
"Provider=Ifxoledbc;Persist Security Info=False;Data Source=stores_demo@ol_informix1170"; connection.Open(); DataTable table = connection.GetSchema(
"DataSourceInformation");   connection.Close();


Generates an exception:


System.InvalidCastException: Specified cast is not valid. at System.Data.OleDb.OleDbMetaDataFactory.GetDataSourceInformationTable(OleDbConnection connection, OleDbConnectionInternal internalConnection) at System.Data.OleDb.OleDbMetaDataFactory.PrepareCollection(String collection Name, String[] restrictions, DbConnection connection) at System.Data.ProviderBase.DbMetaDataFactory.GetSchema(DbConnection connection, String collectionName, String[] restrictions) at System.Data.ProviderBase.DbConnectionInternal.GetSchema(DbConnectionFactory factory, DbConnectionPoolGroup poolGroup, DbConnection outerConnection, String collectionName, String[] restrictions) at System.Data.OleDb.OleDbConnection.GetSchema(String collectionName, String[] restrictionValues) at System.Data.OleDb.OleDbConnection.GetSchema(String collectionName) at ConsoleApplication1.Program.Main(String[] args)


Anyone knows how to fix it?

Thanks.
Updated on 2012-09-17T14:42:53Z at 2012-09-17T14:42:53Z by WKBB_Pavel_Malokhatko
  • SystemAdmin
    SystemAdmin
    1143 Posts
    ACCEPTED ANSWER

    Re: Exception when get DataSourceInformation from ADO.NET OLE DB provider

    ‏2012-09-12T17:17:11Z  in response to WKBB_Pavel_Malokhatko
    Hi,

    The GetSchema method is not supported by Informix .Net provider. You may try the IBM Data Server .Net provider that uses DRDA connection.

    HTH.

    Yunming
  • WKBB_Pavel_Malokhatko
    3 Posts
    ACCEPTED ANSWER

    Re: Exception when get DataSourceInformation from ADO.NET OLE DB provider

    ‏2012-09-14T14:42:46Z  in response to WKBB_Pavel_Malokhatko
    Thanks for the response.

    I develope DLL which can be connected to the different DB and load meta data. The library uses an OLE DB for connection, it is written on .NET. I correctly understood, the OLE DB Informix driver doesn't support the GetSchema() method if use it through ADO.NET? Whether there is a method to get DatasourceInformation not through GetSchema()?

    Thanks.
  • SystemAdmin
    SystemAdmin
    1143 Posts
    ACCEPTED ANSWER

    Re: Exception when get DataSourceInformation from ADO.NET OLE DB provider

    ‏2012-09-14T15:18:07Z  in response to WKBB_Pavel_Malokhatko
    You may access the properties of the OleDbConnection object directly if that is an option.

    All the properties of the OleDbConnection class are listed at http://msdn.microsoft.com/en-us/library/system.data.oledb.oledbconnection_properties(v=vs.71)
  • WKBB_Pavel_Malokhatko
    3 Posts
    ACCEPTED ANSWER

    Re: Exception when get DataSourceInformation from ADO.NET OLE DB provider

    ‏2012-09-17T14:42:53Z  in response to WKBB_Pavel_Malokhatko
    Probably to receive such meta data as DBMS name, DBMS version, the list of keywords through an OLE DB it is impossible. :-( Solved my problem without GetSchema() call. Thanks for the response.