1

I wrote a config tool to easily configure msi installers I create with a Visual Studio Setup project. I successfully edited entries in the InstallExecuteSequence table. Now I would like the change something in the Control table as well but the select query returns 0 entries.

using (Database db = new Database(path, DatabaseOpenMode.Transact))
{
    using (var vw = db.OpenView(db.Tables["Control"].SqlSelectString))
    {
        vw.Execute();

        Record record = vw.Fetch();    // <= this always returns null

        while (record != null)
        {
            record = vw.Fetch();

            if (record == null)
                break;

            if (record["Dialog_"].ToString().ToLower().Contains("CustomCheckA") && record["Control"].ToString().ToLower().Contains("Text"))
            {
                tbName.Text = record["Text"].ToString();
            }

            if (record["Dialog_"].ToString().ToLower().Contains("CustomCheckA") && record["Control"].ToString().ToLower().Contains("BodyText"))
            {
                tbDescription.Text = record["Text"].ToString();
            }
        }

        if (String.IsNullOrEmpty(eintrag.IDString))
            MessageBox.Show("This file does not contain the searched keywords");

       vw.Close();
   }

   db.Close();
}
marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
  • [You could check this answer](https://stackoverflow.com/a/57778570/129130). And [here is a version that uses VBScript and the MSI SDK sample script `"WiRunSQL.vbs"`](https://stackoverflow.com/a/51103086/129130) to update MSI tables and columns. – Stein Åsmul Nov 01 '19 at 13:30
  • What is the SQL string that gets returned by: db.Tables["Control"].SqlSelectString ? – Captain_Planet Nov 04 '19 at 11:41
  • and what happens if you change db.Tables["Control"].SqlSelectString to the string: "SELECT * FROM `Control`" – Captain_Planet Nov 04 '19 at 11:50

1 Answers1

0

I believe you need to add more information of the result you want, but I see something here.

 if (record["Dialog_"].ToString().ToLower().Contains("CustomCheckA") 

You are converting it to lower and then checking if contains that word, but the word is not all lowercase. So the result is always false.

menendeze
  • 1
  • 3
  • Edited the question. The problem is that "record" in line 7 is always null – Christoph Bruns Nov 01 '19 at 07:14
  • 1
    Either way check that out. I don't have a computer to test, but database is readonly while running; you're not changing anything on the db. Try to use readonly. One more thing, check documentation of using, there is no need to call the close method. – menendeze Nov 01 '19 at 07:36