| |

VerySource

 Forgot password?
 Register
Search
View: 632|Reply: 2

Ask about a .net runtime error

[Copy link]

1

Threads

2

Posts

3.00

Credits

Newbie

Rank: 1

Credits
3.00

 China

Post time: 2020-1-17 12:20:01
| Show all posts |Read mode
Failed to enable constraints. One or more rows contain values ​​violating non-null, unique, or foreign-key constraints.

I saw the following solution online. But I didn't understand it too much.
For example, the second one, I did not find where I can turn off EnforceConstraints in the DataSet property.

1. First, as prompted, check whether the returned columns do not allow empty columns or duplicate values. You can also remove the PrimaryKey attribute in the DataSet, which can basically solve these two problems;
2. Turn off EnforceConstraints in the DataSet property;
3. This is my solution to the problem, and it is also encountered by most people: The default length of a field in the DataSet is smaller than the actual returned field length, so an error occurs, so as long as the MaxLength in the property is set greater than the actual Just return the length of the field. If you cannot determine the maximum length of the returned field, you can also set it to -1, which is not limited. I have to set it to -1 because it is a combination of multiple fields. .

Please master click.
Reply

Use magic Report

0

Threads

2

Posts

2.00

Credits

Newbie

Rank: 1

Credits
2.00

 China

Post time: 2020-1-22 14:00:01
| Show all posts
If you look at your code, chances are that the table you are accessing is not what you want, or there is something wrong with your foreign key settings!
Reply

Use magic Report

1

Threads

2

Posts

3.00

Credits

Newbie

Rank: 1

Credits
3.00

 China

 Author| Post time: 2020-2-10 14:45:01
| Show all posts
It was union select null, something went wrong in null.
I have solved it.
Reply

Use magic Report

You have to log in before you can reply Login | Register

Points Rules

Contact us|Archive|Mobile|CopyRight © 2008-2023|verysource.com ( 京ICP备17048824号-1 )

Quick Reply To Top Return to the list