Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
New to MM.NET
Message
De
23/06/2008 17:35:49
 
 
À
Tous
Information générale
Forum:
ASP.NET
Catégorie:
The Mere Mortals .NET Framework
Titre:
New to MM.NET
Versions des environnements
Environment:
C# 3.0
OS:
Windows XP SP2
Network:
Windows 2003 Server
Database:
MS SQL Server
Divers
Thread ID:
01326209
Message ID:
01326209
Vues:
75
Hi,

I am very new to the MM .NET framework and just working through the learning curve.

I am looking for the best method to enforce a unique constraint on a table. I have set up a unique constraint on a varchar field in my table and then used the MM Business Object Wizard to model the table into classes. I can find the validation code for the table, but do not see any code where the framework checks back against the SQL table for uniqueness before attempting the save. When I test the code, I get an exception thrown when the SQL insert statement fails because of the SQL constraint, but I would like to test prior to the statement failing and return something other than a cryptic SQL error to the user.

Inside my validation rules I would like to excute a statement or stored procedure something like the following:

SELECT COUNT(*) AS DupCount FROM MyTable WHERE UniqueColumn = @NewValue

If the count is greater than one, I can send the user a polite "Pick Another Value" message.

Again I am new to MM.NET so I am sure I am just missing something simple, but any help pointing me in the right direction would be appreciated.

Thanks in advance.

Tim Holgerson
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform