MySQL: Problem beim Tabelle kopieren?
Ich habe eine Methode, welche eine Tabelle in eine andere Tabelle kopieren soll.
cn1 = new SqlConnection(cn_string);
cn1.Open();
string sqltext = "SET IDENTITY_INSERT Wochenplan ON;";
cmd = new SqlCommand(sqltext, cn1);
cmd.ExecuteNonQuery();
sqltext = "INSERT INTO Wochenplan ([Text]) SELECT [Text] FROM NächsteWoche;";
cmd = new SqlCommand(sqltext, cn1);
cmd.ExecuteNonQuery(); //Hier der Fehler
sqltext = "SET IDENTITY_INSERT Wochenplan OFF;";
cmd = new SqlCommand(sqltext, cn1);
cmd.ExecuteNonQuery();
Zuvor wurde der Inhalt der Tabelle Wochenplan entfernt.
cn1 = new SqlConnection(cn_string);
cn1.Open();
string sqltext = "DELETE FROM Wochenplan";
cmd = new SqlCommand(sqltext, cn1);
cmd.ExecuteNonQuery();
Nun bekomme ich allerdings beim Ausführen in der Methode vom Kopieren einen Fehler in Zeile 10:
"Explicit value must be specified for identity column in table 'Wochenplan' either when IDENTITY_INSERT is set to ON or when a replication user is inserting into a NOT FOR REPLICATION identity column."
Wie behebe ich das Problem?