L
L
LaraDorren2016-03-24 14:04:13
SQL
LaraDorren, 2016-03-24 14:04:13

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

1 answer(s)
P
pilartser, 2016-03-29
@pilartser

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 question

Ask a Question

731 491 924 answers to any question