I had a problem when using OleDbConnection in conjunction with Oracle. When I query the schema of an existing table using the OleDbConnection FillSchema method, the result seems to be cached somehow.
To reproduce the problem, you need to follow these steps:
create a table called cachetest with one column Request a table cache scheme in your code via FillSchema Change the table by adding a column via alter table cachetest, add column2 char (3) request a cache scheme again. The schema does not contain a column2
OleDbConnection connection = new OleDbConnection(
"Provider=" + "OraOLEDB.Oracle;"
+"Data Source=" + "datasource"
+ ";User Id=" + "msp" + ";"
+ "Password=" + "msp"
+";ChunkSize=1;" + "OLEDB.NET=" + "true;");
connection.Open();
DataTable dt = new DataTable("cachetest");
OleDbDataAdapter adapter_oledb =
new OleDbDataAdapter("select * from cachetest", connection);
adapter_oledb.FillSchema(dt, SchemaType.Source);
int columncount1 = dt.Columns.Count;
OleDbCommand command = new OleDbCommand("alter table cachetest add column2 char(30)", connection);
command.ExecuteNonQuery();
connection.Close();
OleDbConnection connection2 = new OleDbConnection(
"Provider=" + "OraOLEDB.Oracle;"
+"Data Source=" + "datasource"
+ ";User Id=" + "msp" + ";"
+ "Password=" + "msp"
+";ChunkSize=1;" + "OLEDB.NET=" + "true;");
DataTable dt2 = new DataTable("cachetest");
connection2.Open();
OleDbDataAdapter adapter_oledb2 = new OleDbDataAdapter(
"select * from cachetest", connection2);
adapter_oledb2.FillSchema(dt2, SchemaType.Source);
int columncount2 = dt2.Columns.Count;
This problem does not appear using SQL Server ...
Do you have an idea how to solve this problem?
Best regards martin