views:

29

answers:

0

Hi, I got a problem when using OleDbConnection in combination with an oracle Database. When i request the schema of an existing Table using the OleDbConnection's FillSchema Method the result seems to get cached somehow.

To reproduce the Problem you need to do the followin steps:

create a table named cachetest with one column Request a schema of the table cachetest in your code via FillSchema Change the table by adding a column via alter table cachetest add column2 char(3) request the schema of cachetest again. The Schema doesn't contain the 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 doesn't appear using a SQL server...

Do you have any Idea how to solve this problem?

best regards martin