Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
HookSetDefaultValues and DataRow types
Message
 
À
Tous
Information générale
Forum:
ASP.NET
Catégorie:
The Mere Mortals .NET Framework
Titre:
HookSetDefaultValues and DataRow types
Versions des environnements
Environment:
C# 1.1
OS:
Windows XP SP2
Network:
Windows 2003 Server
Database:
MS SQL Server
Divers
Thread ID:
01025290
Message ID:
01025290
Vues:
114
I've modified the Roles table to add a ROWGUIDCOL for replication. In the business object HookSetDefaultValues, we set the rowguid column using a typed DataSet:
protected override void HookSetDefaultValues(DataRow dataRow)
{
	RolesDataSet.RolesRow row = (RolesDataSet.RolesRow)dataRow;
	row.rowguid = Guid.NewGuid();
}
This seems to work fine unless I'm changing the roles for a user via the mmUsersForm. When you do and click "Save", the above hook method gets called, but it's not passed a RolesDataSet.RolesRow, but rather (I think by looking at the call stack) a DataRow from the UserRoles table.

When this happens you get an invalid cast, easy enough to work around. What I'm wondering is why this business objects HookSetDefaultValues method is being called when creating a new row from a different table?

Here's the call stack:
>	adc common business.dll!Adc.Common.Business.Roles.HookSetDefaultValues(System.Data.DataRow dataRow = {System.Data.DataRow}) Line 67	C#
 	mere mortals framework.dll!OakLeaf.MM.Main.Business.mmBusinessObject.NewRow(System.Data.DataSet ds = {Adc.Common.Business.RolesDataSet}, string tableName = "UserRoles", System.Object defaultValues = <undefined value>) + 0x488 bytes	
 	mere mortals framework.dll!OakLeaf.MM.Main.Business.mmBusinessObject.NewRow(System.Data.DataSet ds = {Adc.Common.Business.RolesDataSet}, string tableName = "UserRoles") + 0x3c bytes	
 	mere mortals framework.dll!OakLeaf.MM.Main.Security.mmRole.UpdateUserRoles(System.Object userPK = {1}, System.Data.DataTable dtUserRoles = {Adc.Common.Business.RolesDataSet.RolesDataTable}) + 0x288 bytes	
 	mere mortals framework windows forms.dll!OakLeaf.MM.Main.Windows.Forms.mmUsersForm.mvrRoles_Save(OakLeaf.MM.Main.Business.mmBaseBusinessObject bizObj = {Adc.Common.Business.Users}, OakLeaf.MM.Main.Business.mmBusinessStateChangeEventArgs e = {OakLeaf.MM.Main.Business.mmBusinessStateChangeEventArgs}) + 0x49 bytes	
Thanks,
Mike
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform