SQLite Forum

foreign key issue on deleate
Login
Hello all I have an issue when I try to remove a foreign key from db browser, 


i get the following error, 

Error deleting record: 
Foreign key mismatch - "Programs" referencing "ProgramsList"
(DELETE FROM "main"."ProgramList" WHERE_rowid_IN('1');)

code i have for each table, 

        public void createfulltableUser()
        {
            using (SQLiteCommand command = kiritoconnect.CreateCommand())
            {
                OpenConnection();


                string createfulltableuser = @"CREATE TABLE IF NOT EXISTS
                                               [User] (
                                               [ID] INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
                                               [UserName] TEXT NULL,
                                               [MashineID] TEXT)";

                command.CommandText = createfulltableuser;
                command.ExecuteNonQuery();



                    CloseConnection();
            }
        }

        public void createfulltableprograms()
        {
            {
                using (SQLiteCommand command = kiritoconnect.CreateCommand())
                {
                    OpenConnection();


                    string createfulltableprograms = @"CREATE TABLE IF NOT EXISTS
                                               [Programs] (
                                               [ProgID] INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
                                               [UserName] TEXT NULL,
                                               [MashineID] TEXT,
                                               [Program] TEXT,
                                               [FilePath] TEXT,
                                               [Installed] BOOLEAN,
                                               FOREIGN KEY(`UserName`) REFERENCES `User`(`ID`) ON DELETE CASCADE ON UPDATE CASCADE,
                                               FOREIGN KEY(`Program`) REFERENCES `ProgramList`(`Program`) ON DELETE CASCADE ON UPDATE CASCADE)";

                    command.CommandText = createfulltableprograms;
                    command.ExecuteNonQuery();


                }
                CloseConnection();
            }
        }

        public void createtableprogramlist()
        {
            
            using (SQLiteCommand command = kiritoconnect.CreateCommand())
            {
                OpenConnection();


                string createfulltableprograms = @"CREATE TABLE IF NOT EXISTS
                                               [ProgramList] (
                                               [ProgNumber] INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
                                               [Program] TEXT)";

                command.CommandText = createfulltableprograms;
                command.ExecuteNonQuery();



                CloseConnection();
            }
        }

Creates all db and tables correctly but if i need to delete then it throws the mismatch error if anyone has any ideas what is causing this any help would be much appreciated 

Kind Regards, 
elfenliedtopfan5