Note in vs: the constraint cannot be enabled. One or more rows contain values that violate non-null, unique, or foreign key constraints.

Source: Internet
Author: User

Prompt for running the project today"Constraints cannot be enabled. One or more rows contain values that violate non-null, unique, or foreign key constraints ." .

 

I found some reason online: http://www.cnblogs.com/muzihai1988/archive/2011/05/04/2036502.html

Cause analysis:The query results of a strongly typed able and SQL statement do not match. In short, a strongly typed able has more data columns than the result set queried by SQL statements, or this attribute does not match.

The unique, non-empty, and foreign key constraints of the table used are checked for the error message, and no exception is found. Therefore, the relevant information is queried online. The following methods are provided:

    • the field attribute in datatable is inconsistent with the field attribute in the table, leading to the failure to enable the constraint. modification method: Find ***. the field in the XSD file that corresponds to the table modification, click the attribute of this field ---- the maximum length is equal to the maximum length after the modified field of your data table I thought about it. I did modify a word yesterday. Segment length, and then find the corresponding automatic in XSD, change the length to the new length, and then the error will not appear.
    • In. find the problematic table in the XSD file, use the Shift key with the mouse to select all columns, press delete to delete, right-click the table header, and select "configuration" in the menu ", click "finish" to generate a new forced datetable. The premise of using the preceding method is that the SQL statement in the selectcommand command is similar to the select * from Table statement. If no wildcard is used, you have to modify the SQL statement and then generate a strongly typed able.(This method is not used. An error may be prompted during deletion and cannot be deleted. For more information, seeAttachment)

Attachment: the following error may be prompted during deletion:


This indicates that there is a problem with the database connection. Solution: restart vs, do not open the project, select connect to database in tools to connect to the database, and then open the project.

 

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.