MSSQL+winforms

B

Balint Toth

Hi all,

I am very new to database. I created two tables, and I have two user
controls on my winforms application. In the first usercontrol I use the
first table, in the secund, the secund one.

In the MainForm I have to make some processing with them, I make some
queries with the JOIN of the two tables. But unfortunately it doesn't works,
it sais:

"Additional information: Failed to enable constraints. One or more rows
contain values violating non-null, unique, or foreign-key constraints."

I think the problem is, that the MainForm opens the connection and the
tables, and when the user control tries to open the table, it causes
violation, but I am not sure.

What can be the problem? How can I solve it?

Thanks in advance!

Best regards,
Bálint Tóth
 
W

William Ryan eMVP

Hi Balint:
Balint Toth said:
Hi all,

I am very new to database. I created two tables, and I have two user
controls on my winforms application. In the first usercontrol I use the
first table, in the secund, the secund one.

In the MainForm I have to make some processing with them, I make some
queries with the JOIN of the two tables. But unfortunately it doesn't works,
it sais:

You should probably opt away from the join and do two fills and connect the
tables with a datarelation.
"Additional information: Failed to enable constraints. One or more rows
contain values violating non-null, unique, or foreign-key constraints."

I think the problem is, that the MainForm opens the connection and the
tables, and when the user control tries to open the table, it causes
violation, but I am not sure.
Something is violating the schema of your table, and depending on the way
its set up and the respective schema, you are violating one of your own
rules.

I don't think opening the tables has anything to do with it. When are you
getting the exception too? On dataAdapter.Fill?
What can be the problem? How can I solve it?

Thanks in advance!

Best regards,
Bálint Tóth

Let me know and we'll get you through it.

HTH,

Bill

www.devbuzz.com
www.knowdotnet.com
 
B

Balint Toth

Hi,

yes, I get the exception on dataAdapter.Fill.
I tried the DataRelation, but I got the following exception:
Additional information: This constraint cannot be enabled as not all values
have corresponding parent values.
My source code (I got a table containing url addresses, and emails, with a
url_id field, what tells which email address belongs to which url - more
emails can belong to one url, but not vica versa):

DataColumn parentCol;

DataColumn childCol;

parentCol = dsEmails.Tables["urls"].Columns["id"];

childCol = dsEmails.Tables["emails"].Columns["url_id"];

DataRelation relUrlEmail;

relUrlEmail = new DataRelation("EmailUrl", parentCol, childCol, true);

dsEmails.Relations.Add(relUrlEmail);

Thanks for your help in advance!

Best regards,
Balint Toth
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top