3
Answers

Problem with Deleting rows in MSI database - with particular

Mohan S

Mohan S

10y
886
1

Hello Guys,

My Code:
        private void button3_Click(object sender, EventArgs e)
        {
            FileInfo msiFile = new FileInfo(@"C:\temp\WinInstaller\Sample.msi");
            WindowsInstaller.Installer inst = (WindowsInstaller.Installer)new Installer();
            Database instDb = inst.OpenDatabase(msiFile.FullName, WindowsInstaller.MsiOpenDatabaseMode.msiOpenDatabaseModeTransact);
            WindowsInstaller.View view = instDb.OpenView("DELETE FROM `Registry` WHERE `Registry`.`Root`='1'");
            view.Execute(null);
            view.Close();
            instDb.Commit();
         }

Am trying to delete a row in "Registry" table in MSI Database:


Registry (s72)   Root (i2)    Name (L255)      Value (L0)
69ADA5050611     1  PATH     C:\Program Files\Sample\


 Am successfully in deleting the row with the below combination (tired seperatly with every command)

WindowsInstaller.View view = instDb.OpenView("DELETE FROM `Registry` WHERE `Registry`.`Registry`='69ADA5050611'");
WindowsInstaller.View view = instDb.OpenView("DELETE FROM `Registry` WHERE `Registry`.`Name`='PATH'");
WindowsInstaller.View view = instDb.OpenView("DELETE FROM `Registry` WHERE `Registry`.`Value`='C:\Program Files\Sample\'");


But i want to delete the row using "Root" as refernce, am getting error when i use the below command.

WindowsInstaller.View view = instDb.OpenView("DELETE FROM `Registry` WHERE `Registry`.`Root`='1");  --- Getting error when i use Root as reference for deleting row

I get runtime error for the above line "COMException was unhandled OpenView,Sql"
How to delete the row using Root as reference.
Please suggest.

Cheers,

Answers (3)