c# 4.0 - ON DELETE CASCADE not working in c# -
When I removed the primary key of the first table in the ExecuteNonQuery ()
is not The second table affects but when I do it with SQLiteStudio, it affects the second table.
This is my SQLite code:
Make Table Zdravila (ID integer primary key, NACIONALNA_SIFRA INTEGER UNIQUE NOT NULL, IME_ZDRAVILA text, POIMENOVANJE_IZDELKA text not NULL, SIFRA_REZIM_IZDAJE Integer not NULL , ATC_OZNAKA text not NULL, NAZIV_POTI_UPORABE text not NULL, foreign key (NACIONALNA_SIFRA) reference LastnostiZdravila (NACIONALNA_SIFRA)) on CASCADE update removes CASCADE; Create table LastnostiZdravila (NACIONALNA_SIFRA integer primary key, NAZIV_FARMACEVTSKE_OBLIKE text not NULL, KOLICINA_OSNOVNE_ENOTE not integer NULL test (KOLICINA_OSNOVNE_ENOTE & gt; 0), OZNAKA_OSNOVNE_ENOTE text not NULL, PAKIRANJE text not NULL, SIFRA_IMETNIKA_DOVOLJENJA text not NULL); Pargama foreign_kiz = current;
and my C # code:
SQLiteConnection conn = new SQLiteConnection (poveziZBazo); SQLiteCommand sqlQuery = New SQLiteCommand (sql); SqlQuery.Connection = conn; Conn.Open (); SQLiteTransaction trans; Trans = conn.BeginTransaction (); SqlQuery.CommandText = sql; J = sqlQuery.ExecuteNonQuery (); Trans.Commit (); SqlQuery.Dispose (); Conn.Close ();
And my query: "Delete last Nostijdravila where NACIONALNA_SIFRA =" + "" + Nasionlna recommends Brabirjheje + "" + "; ";
As of now, it is still wrong.
said After each connection to SQLite This is what SQLiteStudio does internally and this is why it works. foreign_keys
setting is "per connection" - what does it mean that every time you create a new connection to the SQLite database, Videshi_kijh
pragma set to default values Ho > Line is that false
PRAGMA foreign_keys = 1;
needs to be executed, so the foreign key Your C # application has been awarded.
Comments
Post a Comment