DataTable causes constraints not to be enabled

Source: Internet
Author: User

Modify an earlier project today. After running the project and select a query page, the system prompts "constraints cannot be enabled. One or more rows contain values that violate non-null, unique, or foreign key constraints ." .

Cause analysis: the results of the strong DataTable and SQL statement queries 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, resulting in the failure to enable the constraint. Modification Method: Find the field corresponding to the table modification in the ***. xsd file and click the attribute of this field. The maximum length is equal to the maximum length after the modified field of your data table.

• 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 has never been used. An error may be prompted during deletion and cannot be deleted. See the attachment)

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.

Recommended by editors]

Related Article

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.