首页 > 解决方案 > 从 msi 文件中选择行的问题

问题描述

我编写了一个配置工具来轻松配置我使用 Visual Studio 安装项目创建的 msi 安装程序。我成功地编辑了表格中的条目InstallExecuteSequence。现在我也想更改Control表中的某些内容,但选择查询返回 0 个条目。

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();
}

标签: c#databasewindows-installer

解决方案


我相信你需要添加更多关于你想要的结果的信息,但我在这里看到了一些东西。

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

您将其转换为小写,然后检查是否包含该单词,但该单词并非全部小写。所以结果总是错误的。


推荐阅读