DataAdapter.Fill doesn't include PrimaryKey Info
398042Nov 22 2004 — edited Nov 29 2004We are using Oracle 9i and Odp.net verion 9.2.0.401.
I am using the data adapter on a command that is a simple select statement in our code. The code is written generically to support multiple providers using ado.net.
The problem I am having is that when I call Fill with "adapter.MissingSchemaAction = MissingSchemaAction.AddWithKey" specified that DataTable comes back with no primary key. Other providers bring this information back.
I read in the manual that indicates that "schema and key information is not brought back even if MissingSchemaAction = MissingSchemaAction.AddWithKey is specified". This seem to function a bit different than other providers (both SqlServer and Oracle).
How would I load this info when I load the table using fill?
Thanks in advance
Sample of our code:
public static DataTable LoadTable(string name)
{
IDbTransaction transaction = null;
IDbConnection connection = null;
DataSet dataSet = new DataSet();
string query = string.Format("SELECT * FROM {0}", name);
DataTable tableToReturn = null;
try
{
OpenConnection(out connection, out transaction);
IDbCommand command = InterfaceDataProvider.CreateCommand(transaction.Connection, transaction, query);
DbDataAdapter adapter = InterfaceDataProvider.CreateAdapter(command);
adapter.MissingSchemaAction = MissingSchemaAction.AddWithKey;
adapter.Fill(dataSet, name);
tableToReturn = dataSet.Tables[name];
}
finally
{
CloseConnection(connection);
}
return tableToReturn;
}