Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Disallowing duplicate values
Message
From
05/03/2010 09:26:13
Timothy Bryan
Sharpline Consultants
Conroe, Texas, United States
 
 
To
05/03/2010 09:17:15
General information
Forum:
ASP.NET
Category:
The Mere Mortals .NET Framework
Miscellaneous
Thread ID:
01452754
Message ID:
01452791
Views:
27
>>>>>>Hi,
>>>>>>
>>>>>>I want to disallow duplicate values from being entered. For example, I have a table of Countries where I do not want duplicate country names. I have set a UNIQUE constraint on the Country Name field in SQL Server, but the UI did not automatically pick this up. Should it?
>>>>>>
>>>>>>I then found some sample code in the Developer's Guide which does a dynamic SQL select to check for duplicates and this code is called as one of the business rules. My thinking is that if the timing is perfect, two people could run this code at the exact same time and the rule will not detect duplicates so the users will then get an error from SQL Server. I know this is highly unlikely, but it is possible.
>>>>>>
>>>>>>What is the best way to handle this?
>>>>>
>>>>>
>>>>>Putting a business rule is the best way to handle this along with the constraint in your database. In the unlikely event two records get saved at the exact same time the database would reject it.
>>>>>Tim
>>>>
>>>>Thanks. Is it suggested to write a generic bit of code that would handle this? In VFP I would have a program that I pass in the table name, field name ID and value and then return true or false depending on if a duplicate was found or not.
>>>
>>>You could certainly do that if you were inclined. That would go in the ABusiness Object and you have reference to the table name already as this.TableName. I just did a similar generic method in ABusiness Object two days ago. You would just need to pass in a field name and value.
>>>Tim
>>Correction Frank, that would go in ABusinessRule
>
>Thanks.
>
>Did you get my email?

Yup, just replied.
Timothy Bryan
Previous
Reply
Map
View

Click here to load this message in the networking platform