General information
Category:
The Mere Mortals .NET Framework
Environment versions
Network:
Windows 2003 Server
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
Next
Reply
View the map of this thread
View the map of this thread starting from this message only
View all messages of this thread
View all messages of this thread starting from this message only