MissingPrimaryKeyException Error while Searching an Access Table in VB2008
Posted on 2008-10-29
I'm new to VB2008 and ADO.NET. I've been using VB6 with DAO extensively and have just started to upgrade to VB2008.
I'm using the following code to try to search for a Value in an Access table. The field that I am trying to search is called "ID".
Dim foundRow As DataRow
Dim findThis As Object
findThis = 21844
foundRow = objDataSet.Tables(0).Rows.Find(findThis)
I'm getting the following error message on the last line, even though the ID field is set in the table as a Primary Key field:
System.Data.MissingPrimaryKeyException was unhandled
Message="Table doesn't have a primary key."
Any help would be appreciated. Thanks.