【问题标题】:Problem with selecting rows from msi file从 msi 文件中选择行的问题
【发布时间】:2019-11-02 16:04:27
【问题描述】:

我编写了一个配置工具来轻松配置我使用 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# database windows-installer


【解决方案1】:

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

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

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

【讨论】:

  • 编辑了问题。问题是第 7 行中的“记录”始终为空
  • 无论如何都要检查一下。我没有要测试的计算机,但数据库在运行时是只读的;你没有改变数据库上的任何东西。尝试使用只读。还有一件事,查看使用文档,不需要调用close方法。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2015-10-13
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2018-02-21
相关资源
最近更新 更多