Answer the question
In order to leave comments, you need to log in
Constraint failed UNIQUE constraint failed?
I have created several softwares, all of them should work from the same database. Two of them worked fine, later one began to swear at the request to update data in the database with the error constraint failed
UNIQUE constraint failed: moz_cookies.name, moz_cookies.host, moz_cookies.path, moz_cookies.originAttributes. Who faced, what do you advise? I am attaching the code:
SQLiteCommand sqLiteCommand = new SQLiteCommand();
SQLiteConnection qLiteConnection = new SQLiteConnection(@"DataSource= " + profileCookies);
sqLiteCommand.CommandText =
"UPDATE moz_cookies SET Id='"+cookie.Id+"',BaseDomain = '" + cookie.BaseDomain + "', " +
"originAttributes='"
qLiteConnection.Open();
sqLiteCommand.Connection = SqLiteConnection;
sqLiteCommand.ExecuteNonQuery();
qLiteConnection.Close();
Answer the question
In order to leave comments, you need to log in
Do not violate the unique constraint.
You are trying to add an entry to the moz_cookies table containing such a data set in the name, host, path, originAttributes fields that already exists in your table. This is contrary to the restriction you imposed.
Read about Unique .
Read about passing parameters to a request.
Read about string concatenation .
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question