Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Missing PrimaryKey exception
Message
De
20/03/2007 17:34:29
 
 
À
Tous
Information générale
Forum:
ASP.NET
Catégorie:
The Mere Mortals .NET Framework
Titre:
Missing PrimaryKey exception
Divers
Thread ID:
01206288
Message ID:
01206288
Vues:
97
Hi Kevin,

I run into the "Missing Primary Key exception" (table doesn't have a primary key) when trying to use the delete method passing a Pk + table name as parameters. Tracing the code, the exception is raised in the following line of code:
// Find the specified row
DataRow FoundRow = ds.Tables[tableName].Rows.Find(primaryKeyValue);
It seems that the primaryKey is never created on the table and that's what is raising the exception. How can I ensure that a primary key value is created for the table?. When does MM do it? My BO new method defines the PrimaryKey property in it. I am not sure if that's what defines the PK in the table to then be able to be used by a find mehtod.
Public Sub New()
        Me.TableName = "TAX_RATE_TYPE"
        Me.PhysicalDbcObjectName = "TRUCKING.PKG_TAX_RATE_TYPE.TAX_RATE_TYPE"
        Me.PrimaryKey = "TAX_RATE_NUMBER"
       Me.DefaultCommandType = CommandType.StoredProcedure
End Sub
This is my code in the delete procedure.
 Dim PK As Object = Me.oMainBizObj.GetPrimaryKeyValue(Me.oMainBizObj.DataRow)
 Dim TableName As String = Me.oMainBizObj.TableName
 Me.oMainBizObj.Delete(PK, TableName)
Thanks
Mario
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform