R
R
Rom Black2012-03-11 18:09:05
MySQL
Rom Black, 2012-03-11 18:09:05

MySQL: Foreign key error?

I am writing a client in C# for a database on MySQL (connection via mysql.Net connector) I encountered such a problem.
Given are reference tables and a pivot table.
For example, one of the directories Counterparties
61257.png
, add a new counterparty to it,
61258.png
the code of the save button

try
            {
                this.Validate();
                this.contragentBindingSource.EndEdit();
                this.tableAdapterManager.UpdateAll(this.contractDataSet);
                this.contractsDataGridView.Update();

                MessageBox.Show("Данные обновлены успешно!", "Договоры", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
catch
            {
                MessageBox.Show("Ошибка обновления данных!", "Договоры", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }

The agent is added to the mysql table normally)
now, we want to correct the existing contract, or edit the existing one, by selecting the newly added counterparty
for which, when saving the data, an error occurs
61259.png
. If you relogin to the client and select the counterparty, then everything works fine.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
F
freeek, 2012-03-11
@freeek

I didn’t write clients in C#, but are you sure that the transaction is committed when a new counterparty is added?

T
TrueDrago, 2012-03-12
@TrueDrago

Make a request to edit the contract, see what data they want to insert, then see if there is a foreign key in the database with which you are trying to add a record.
Look for inconsistencies there, but most likely, as already said, the transaction commit does not go through until the exit from the client.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question