Determine if the unique constraint is unique

Source: Internet
Author: User

Check UNIQUE constraint name

            // check UNIQUE constraint name            int New Bll. Funcs (). GetRecordCount (string. Format ("name={0}", model. Name));             if (! Checkuniquefieldbycount (Editid, Count, Prename, model. Name)            {                FineUI.Alert.Show (Resources.WebResource.SaveFailed);                 return ;            }

The new and edited unique validation is different and must be judged separately:

        /// <summary>        ///Check for UNIQUE constraints/// </summary>        /// <param name= "Editid" >Edit ID</param>        /// <param name= "Count" >the number of queries based on the current name</param>        /// <param name= "Prename" >Original Name Value</param>        /// <param name= "NewName" >New Name Value</param>        /// <returns>is unique</returns>        protected BOOLCheckuniquefieldbycount (intEditid,intCountstringPrename,stringnewName) {            if(Editid >0)            {                //if the name already exists that is not itself                if(Count >1|| (Count = =1&& NewName! =prename)) {                    return false; }            }            Else            {                //if the name already exists                if(Count >0)                {                    return false; }            }            return true; }

Determine if the unique constraint is unique

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.