IBM DB2
На некоторых серверах при попытке чтения записей вылетает такой Exception
'IBMDADB2' failed with no error message available, result code: E_FAIL(0x80004005). at System.Data.OleDb.OleDbDataReader.ProcessResults(OleDbHResult hr) at System.Data.OleDb.OleDbDataReader.BuildSchemaTableRowset(Object handle) at System.Data.OleDb.OleDbDataReader.GenerateSchemaTable(OleDbDataReader dataReader, Object handle, CommandBehavior behavior) at System.Data.OleDb.OleDbCommand.ExecuteReaderInternal(CommandBehavior behavior, String method) at System.Data.OleDb.OleDbCommand.ExecuteReader(CommandBehavior behavior) at System.Data.OleDb.OleDbCommand.System.Data.IDbCommand.ExecuteReader(CommandBehavior behavior) at System.Data.Common.DbDataAdapter.FillSchemaInternal(DataSet dataset, DataTable datatable, SchemaType schemaType, IDbCommand command, String srcTable, CommandBehavior behavior) at System.Data.Common.DbDataAdapter.FillSchema(DataSet dataSet, SchemaType schemaType, IDbCommand command, String srcTable, CommandBehavior behavior) at System.Data.Common.DbDataAdapter.FillSchema(DataSet dataSet, SchemaType schemaType) at BusinessLogiс.DB2.Database.GetData(String query, String database, String host, String port, String login, String password)
public static DataTable GetData(string query, string database, string host, string port, string login, string password)
{
OleDbConnection connection = null;
try
{
connection = Connection.GetConnection(database, host, port, login, password);
OleDbDataAdapter dataAdapter = new OleDbDataAdapter(query, connection);
DataSet dataSet = new DataSet();
dataAdapter.FillSchema(dataSet, SchemaType.Mapped);
dataAdapter.Fill(dataSet);
return dataSet.Tables[0];
}
finally
{
Connection.CloseConnection(connection);
}
}
ublic static OleDbConnection GetConnection(string database, string host, string port, string login, string password)
{
string connectionString = string.Format("Provider=IBMDADB2;Database={0};Hostname={1};Protocol=TCPIP;Port={2};Uid ={3};Pwd={4};", database, host, port, login, password);
OleDbConnection connection = new OleDbConnection(connectionString);
connection.Open();
return connection;
}