Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/335.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/database/10.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 从msi文件中选择行时出现问题_C#_Database_Windows Installer - Fatal编程技术网

C# 从msi文件中选择行时出现问题

C# 从msi文件中选择行时出现问题,c#,database,windows-installer,C#,Database,Windows Installer,我编写了一个配置工具来轻松配置我用VisualStudio安装项目创建的msi安装程序。我成功地编辑了InstallExecuteSequence表中的条目。现在,我也希望在控件表中进行一些更改,但是select查询返回0个条目 using (Database db = new Database(path, DatabaseOpenMode.Transact)) { using (var vw = db.OpenView(db.Tables["Control"].SqlSelectStr

我编写了一个配置工具来轻松配置我用VisualStudio安装项目创建的msi安装程序。我成功地编辑了
InstallExecuteSequence
表中的条目。现在,我也希望在
控件
表中进行一些更改,但是select查询返回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=新数据库(路径,DatabaseOpenMode.Transact))
{
使用(var vw=db.OpenView(db.Tables[“Control”].SqlSelectString))
{
vw.Execute();

Record Record=vw.Fetch();//我认为您需要添加更多关于所需结果的信息,但我在这里看到了一些东西

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

您正在将其转换为小写,然后检查是否包含该单词,但该单词不全是小写。因此结果总是错误的。

我认为您需要添加更多有关所需结果的信息,但我在这里看到了一些东西

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

您正在将其转换为小写,然后检查是否包含该单词,但该单词并非全部为小写。因此结果始终为false。

编辑了该问题。问题是“记录”在第7行中,无论哪种方式都始终为空。我没有要测试的计算机,但数据库在运行时是只读的;您没有在数据库上更改任何内容。请尝试使用只读。另外,请检查使用的文档,不需要调用close方法。编辑了问题。问题是“record”在第7行中,无论哪种方式都始终为空。我没有要测试的计算机,但数据库在运行时是只读的;您没有在数据库上更改任何内容。请尝试使用只读。另外,请检查使用的文档,无需调用close方法..并更新MSI表和列。返回的SQL字符串是什么由:db.Tables[“Control”].SqlSelectString打开,如果将db.Tables[“Control”].SqlSelectString更改为字符串:“SELECT*FROM
Control
”,并更新MSI表和列,那么:db.Tables[“Control”].SqlSelectString返回的SQL字符串是什么?如果更改db.Tables[“Control”]会发生什么.SqlSelectString到字符串:“从
控件中选择*