OleDb data provider give error E_NOINTERFACE

0

c# code that doesn't work:

string connectionString = "Provider=OvHOleDbProv.OvHOleDbProv.1;Persist Security Info=True;User ID=user;Password=password;Data Source=192.168.7.96;Location=\"\";Mode=ReadWrite;Extended Properties=\"\";";
OleDbConnection _connection = new OleDbConnection(connectionString);
_connection.Open();
DataTable schema = _connection.GetSchema("Tables"); // Exception see below
_connection.Close();

Exception:

System.Data.OleDb.OleDbException (0x80004002): Сбой "OvHOleDbProv.OvHOleDbProv.1" без сообщения об ошибке, код результата: E_NOINTERFACE(0x80004002).

в System.Data.OleDb.OleDbConnectionInternal.ProcessResults(OleDbHResult hr)

в System.Data.OleDb.OleDbConnectionInternal.GetSchemaRowset(Guid schema, Object[] restrictions)

в System.Data.OleDb.OleDbConnection.GetOleDbSchemaTable(Guid schema, Object[] restrictions)

в System.Data.OleDb.OleDbMetaDataFactory.PrepareCollection(String collectionName, String[] restrictions, DbConnection connection)

в System.Data.ProviderBase.DbMetaDataFactory.GetSchema(DbConnection connection, String collectionName, String[] restrictions)

в System.Data.ProviderBase.DbConnectionInternal.GetSchema(DbConnectionFactory factory, DbConnectionPoolGroup poolGroup, DbConnection outerConnection, String collectionName, String[] restrictions)

в System.Data.OleDb.OleDbConnection.GetSchema(String collectionName, String[] restrictionValues)

в System.Data.OleDb.OleDbConnection.GetSchema(String collectionName)

в SourceModule.Ovation.ApiOvation.ExportSignals(String filename) в E:\tfs\vm-tfs\SAn\Source code\SourceModules\Ovation\Development\Version 2\SourceModule.Ovation\ApiOvation.cs:строка 58

в SourceModule.Ovation.Program.Main(String[] args) в E:\tfs\vm-tfs\SAn\Source code\SourceModules\Ovation\Development\Version 2\SourceModule.Ovation\Program.cs:строка 20

c# code that works:

string connectionString = "Provider=OvHOleDbProv.OvHOleDbProv.1;Persist Security Info=True;User ID=user;Password=password;Data Source=192.168.7.96;Location=\"\";Mode=ReadWrite;Extended Properties=\"\";";
OleDbConnection _connection = new OleDbConnection(connectionString);
_connection.Open();
DataTable schema = _connection.GetSchema("Restrictions");
_connection.Close();

PS code that works for both cases:

$connectionString='Provider=OvHOleDbProv.OvHOleDbProv.1;Persist Security Info=True;User ID=user;Password=password;Data Source=192.168.7.96;Location="";Mode=ReadWrite;Extended Properties="";' 
$oCon = New-Object System.Data.OleDb.OleDbConnection $connectionString 
$oCon.Open() 
$schema = New-Object System.Data.DataTable
$schema = $oCon.GetSchema("Tables") 
$schema
$schema = $oCon.GetSchema("Restrictions")
$schema
$oCon.Close()

Restrictions output include collectionName "Tables":

CollectionName RestrictionName RestrictionDefault RestrictionNumber
-------------- --------------- ------------------ -----------------
Columns TABLE_CATALOG 1
Columns TABLE_SCHEMA 2
Columns TABLE_NAME 3
Columns COLUMN_NAME 4
Tables TABLE_CATALOG 1
Tables TABLE_SCHEMA 2
Tables TABLE_NAME 3
Tables TABLE_TYPE 4

c#
powershell
oledb
asked on Stack Overflow Mar 18, 2018 by Ageev Dmitry • edited Mar 18, 2018 by Ageev Dmitry

1 Answer

0

The following code returns a list of tables in the database and save to xml:

string connectionString = "Provider=OvHOleDbProv.OvHOleDbProv.1;Persist Security Info=True;User ID=user;Password=password;Data Source=192.168.7.96;Location=\"\";Mode=ReadWrite;Extended Properties=\"\";";
OleDbConnection connection = new OleDbConnection(connectionString);
connection.Open();
OleDbCommand command = new OleDbCommand() { Connection = connection, CommandText = "select TABLE_NAME from SYSTABLES where TABLE_TYPE='TABLE'" };
OleDbDataReader datareader = command.ExecuteReader();
DataTable data = new DataTable();
data.Load(datareader);
data.TableName = "SYSTABLES"; // necessary for writing to xml
data.WriteXml("tables.xml");
connection.Close();
answered on Stack Overflow Mar 26, 2018 by Ageev Dmitry • edited Mar 27, 2018 by Ageev Dmitry

User contributions licensed under CC BY-SA 3.0