user1192369
user1192369

Reputation: 103

How can I insert values to msi table

I'm using Wix for intalling application & service, and I want to change the values in the msi table(session.database).

I tried to do it with a custom action, I can select values from the table using select statement, but if I try to insert, the setup fails.

My code:

 [CustomAction]
 public static ActionResult MyCustomAction1(Session session)
 {
     ServiceController serviceController = new ServiceController(serviceName);

     //-----Works fine-----
     res=session.Database.ExecuteIntegerQuery("select ServiceType from ServiceInstall where StartType=4");

     //----Makes the setup fail
     session.Database.Execute("insert into ServiceInstall (ServiceInstall) values ('a')");       
     return ActionResult.Success;
  }

Is it possible to insert values with custom action?

Thanks


Thank you' I've tried this: session.Database.Execute("insert into ServiceInstall (Name) values ('ezm') TEMPORARY");

But I get the folloing exception: Exception:Function failed during execution. Database: Table(s) Update failed.

Upvotes: 3

Views: 1925

Answers (1)

Yan Sklyarenko
Yan Sklyarenko

Reputation: 32270

You can only insert temporary data into the MSI database at install time. There's a special syntax for this - INSERT INTO {table} ({column-list}) VALUES ({constant-list}) [TEMPORARY]. Pay attention to the last word - although it is optional, it MUST be present if you try to insert data from custom action.

Upvotes: 1

Related Questions