Home All Groups Group Topic Archive Search About

DataTable.PrimaryKeys returns nothing from Oracle

Author
17 Nov 2005 6:06 PM
sanchisudhir
Hi,
I am not sure if this is the right place to post this. But here i go.

I am trying to fill a datatable from oracle with the primary key &
constraints info. But what ever i try the PrimaryKeys array is always
returned nothing. I have seen few post on similar problem but not one
has a solution i can find.

Here's my code. Plain & Simple.

**--------------------------------------------------------------------------**
      cn.ConnectionString = "Provider=MSDAORA.1;Password=password;User
ID=userid;Data           Source=Oracle02;Persist Security
Info=True;hostname=ipaddress;port=1521"
      cn.Open()

        Dim dAdapter As New OleDbDataAdapter
        dAdapter.SelectCommand = New OleDbCommand("Select * From
myTable", cn)

        '//create CommandBuilder
        Dim cmdBuilder As New OleDbCommandBuilder(dAdapter)

        '//create DataSet
        Dim dSet As New DataSet

        dAdapter.MissingSchemaAction = MissingSchemaAction.AddWithKey
        dAdapter.FillSchema(dSet, SchemaType.Source, "myTable")
        dAdapter.Fill(dSet, "myTable")

        MessageBox.Show("Column Count: " +
dSet.Tables("myTable").PrimaryKey.Length.ToString())

**--------------------------------------------------------------------------**

dSet.Tables("myTable").PrimaryKey is always returned nothing. The table
i am using has primary key & constraint.

Thanks in advance for ur help,
Sudhir

AddThis Social Bookmark Button