Name
MissingPrimaryKeyException
Synopsis
This exception is thrown when you attempt to invoke the
DataRowCollection.Contains( )
or
DataRowCollection.Find( )
method on a
DataTable
that has no primary key. To retrieve
primary key information, you can use the
IDataAdapter.FillSchema( )
method when accessing a
data source. To programmatically set a primary key, you must add a
UniqueConstraint
(typically by setting the
DataColumn.Unique
property of the primary key
field to true
) and then set the
UniqueConstraint.IsPrimaryKey
property to
true
.
public class MissingPrimaryKeyException : DataException { // Public Constructors public MissingPrimaryKeyException( ); public MissingPrimaryKeyException(strings
); // Protected Constructors protected MissingPrimaryKeyException(System.Runtime.Serialization.SerializationInfoinfo
, System.Runtime.Serialization.StreamingContextcontext
); }
Hierarchy
System.Object
→
System.Exception(System.Runtime.Serialization.ISerializable)
→
System.SystemException
→
DataException
→
MissingPrimaryKeyException
Get ADO.NET in a Nutshell now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.