Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Checking for unique values
Message
 
À
07/08/2008 11:59:13
Timothy Bryan
Sharpline Consultants
Conroe, Texas, États-Unis
Information générale
Forum:
ASP.NET
Catégorie:
The Mere Mortals .NET Framework
Versions des environnements
Environment:
C# 2.0
OS:
Windows Server 2003
Network:
Windows 2003 Server
Database:
MS SQL Server
Divers
Thread ID:
01337135
Message ID:
01337270
Vues:
16
Hi Tim,

Yes, that's exactly the error I was getting. I had put a break point at the beginning of the checkruleshook but never got there. I'm not sure where to put the breakpoint on the save button because I think all this code fires before the click method. I'll have to dig around to figure out something. I guess I can put a breakpoint somewhere in the mmBusinessObject. Thanks.

>Hi Linda,
>
>Does your error look like this: ... Ok, I guess I can't post a screen shot here after all. I can email it to you if you want.
>What I did was open the jump start windows application and in an existing order I clicked new on the OrderDetail grid. I tried to add a new record with the same OrderId and ProductId of an existing detail. This brings up an error message (ugly) that says a constraint is being violated. I am wondering if this is the same type message you are getting? I was going to use this as a starting point to try to replcate what you are doing.
>
>Tim
>
>
>>Hi Tim,
>>I am just using the regular mmButtonSave on the tab page. I added the rule in the rule class and placed the call in the rule that the business layer generator built for checking for empty values, just to keep all the validation for the same field grouped together. The code never reaches the CheckRulesHook before triggering the SQL error. I don't want to remove the rule from the database side because it's not beyond the realm of possibility that someone could add a record directly.
>>
>>You managed to answer this before my update. I tried to put this code in the HookPreSave method but it wouldn't let me call the mmAppDeskTop.FormMgr.Show() method, so I'm not sure how to tell the user what the problem is. Would I just add a broken rule from here?
>>
>>Then I tried the Validating method of the text box but I don't see a way to indicate that the value is not valid because the Validating method doesn't return a value. For now, I have just forced the value to blank so it will get trapped by the test for blank id's but that's not a great solution.
>>
>>I had followed the thread recommended by Bob Flanagan but, unless I'm missing something, it doesn't address any of these issues.
>>
>>
>>
>>>Hi Linda,
>>>
>>>>I have a uniquenes constraint on my SQL Server table. I want to check for uniqueness in a rule before getting an error in SQL Server. I added a rule in the rule class. However, the SQL error is triggering before the rule code is ever run. Do I need to put this code in the HookPreSave method? I'd really like to keep all the rule stuff together, if possible. Thanks.
>>>
>>>Seems to me you got it right by having the rule in the rule class. Are you calling your save at the form level or the business object? You added the rule and then placed the call to it in CheckRulesHook()?
>>>Tim
Linda Harmes
HiBit Technologies, Inc.
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform