title: datatable not knowing its primary key
body: <p>I'm trying to query a datatable to establish the primary key [identity column], by querying each columns autoincrement property.  However its always false (for the column which is the Idenity/PK).</p>
  
  <p>Querying the tables primary key collection reveals that the datatable doesn't think it has a PK.;</p>
  
  <pre><code>  Dim dc As DataColumn() = dt.PrimaryKey
    Debug.WriteLine(dc.Count)  'Result is 0
  </code></pre>
  
  <p>The datatable is being populated....... </p>
  
  <pre><code>Using cn As SqlConnection = MyApp.GetConnection
    Using cmd As New SqlCommand(strSQL, cn)
      Using da As New SqlDataAdapter(cmd)
        Dim ds As New DataSet
        Try
          da.Fill(ds)
  
          Return ds
  
        Catch ex As Exception
          MyAppClass.LogWarning(ex, EventLogEntryType.Error)
          Throw
        End Try
      End Using 
    End Using 
  End Using
  </code></pre>
  
  <p>The table in question's primary key is : ([myTableId] [int] IDENTITY(1,1) NOT NULL).
  and its the pk : CONSTRAINT [PK_myTablesPK] PRIMARY KEY CLUSTERED ( [myTableId] ASC )</p>
  
  <p>Here's someone having the same problem (perhaps its clearer than what i've written) : <a href="http://social.msdn.microsoft.com/Forums/en-US/adodotnetdataproviders/thread/c6abdeef-0cb0-42f5-a5f1-10dc4d81df4a/" rel="nofollow noreferrer">http://social.msdn.microsoft.com/Forums/en-US/adodotnetdataproviders/thread/c6abdeef-0cb0-42f5-a5f1-10dc4d81df4a/</a></p>
  
  <p>I'm assuming its something simple i'm missing, does anyone care to enlighten me?</p>