【发布时间】: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();
}
【问题讨论】:
-
db.Tables["Control"].SqlSelectString 返回的 SQL 字符串是什么?
-
如果将 db.Tables["Control"].SqlSelectString 更改为字符串会发生什么:"SELECT * FROM
Control"
标签: c# database windows-installer