.net cf OracleDataReader.GetSchemaTable()

Discussion of open issues, suggestions and bugs regarding ADO.NET provider for Oracle
Post Reply
Alex56
Posts: 2
Joined: Mon 25 Oct 2010 15:56

.net cf OracleDataReader.GetSchemaTable()

Post by Alex56 » Mon 25 Oct 2010 16:03

I am working with Oracle 11g database from a mobile device. I noticed that when I create reader against a table on the server and get schema for that table via

Code: Select all

OracleDataReader.GetSchemaTable()
the schema table never has primary key column, ["IsKey"], set to true. However, if I get schema on the same table via
OracleDataTable.GetSchemaTable()
it does get PK correctly.

Has anyone experienced the same issue ?

Shalex
Site Admin
Posts: 9543
Joined: Thu 14 Aug 2008 12:44

Re: .net cf OracleDataReader.GetSchemaTable()

Post by Shalex » Wed 27 Oct 2010 17:27

Alex56 wrote:I am working with Oracle 11g database from a mobile device. I noticed that when I create reader against a table on the server and get schema for that table via

Code: Select all

OracleDataReader.GetSchemaTable()
the schema table never has primary key column, ["IsKey"], set to true.
Standard .NET Framework providers (OracleClient, ODP.NET) show the same behaviour. We will investigate this issue and notify you about the results.
Alex56 wrote:However, if I get schema on the same table via

Code: Select all

OracleDataTable.GetSchemaTable()
it does get PK correctly.
Devart.Data.Oracle.OracleDataTable doesn't have public GetSchemaTable() method. Please correct your sample. Do you mean OracleDataTable.WriteXmlSchema()?

Shalex
Site Admin
Posts: 9543
Joined: Thu 14 Aug 2008 12:44

Post by Shalex » Fri 29 Oct 2010 09:20

1.
OracleDataReader.GetSchemaTable()
This is a designed behaviour. To get the primary key information, including whether a field is a part of a primary key and whether it is an AutoIncrement field, you should set the CommandBehavior.KeyInfo parameter of the OracleCommand.ExecuteReader() method when getting your data reader: http://support.microsoft.com/kb/310107. We will add this info to our documentation.

Code: Select all

    OracleDataReader reader = cmd.ExecuteReader(CommandBehavior.KeyInfo);
    DataTable table = reader.GetSchemaTable();
2.
OracleDataTable.GetSchemaTable()
Probably you meant the OracleDataTable.SchemaTable property. OracleDataTable always requests the PK info on its opening. This explains the result you have got.

Alex56
Posts: 2
Joined: Mon 25 Oct 2010 15:56

Post by Alex56 » Fri 29 Oct 2010 17:11

Thank you for the explanation.

On #1 Yes, the ExecuteReader() either takes no arguments or enum System.Data.CommandBehavior.
I just tested that and with CommandBehaviou = CommandBehavior.KeyInfo and was able to get successfully the information I needed.

On #2 You are correct, I meant the property SchemaTable of the OracleDataTable object.

Post Reply