Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/wix/2.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# Wix-Msi:如何检查Msi数据表中是否存在特定行_C#_Wix_Windows Installer - Fatal编程技术网

C# Wix-Msi:如何检查Msi数据表中是否存在特定行

C# Wix-Msi:如何检查Msi数据表中是否存在特定行,c#,wix,windows-installer,C#,Wix,Windows Installer,我想检查数据表中是否存在特定的行 例如,我想检查msi数据表中是否存在属性表。如果它存在,那么我想检查“属性”列和“值”列是否存在。如果两者都存在,那么我想检查属性“ARPNOMODIFY”是否存在 if (database.Tables.Contains("Property")) { if (database.Tables["Property"].Columns.Contains("Prop

我想检查数据表中是否存在特定的行

例如,我想检查msi数据表中是否存在属性表。如果它存在,那么我想检查“属性”列和“值”列是否存在。如果两者都存在,那么我想检查属性“ARPNOMODIFY”是否存在

                if (database.Tables.Contains("Property"))
                {
                    if (database.Tables["Property"].Columns.Contains("Property"))
                    {
                        // here I want to checked if "ARPNOMODIFY" or any other property exists or not. If it exists then I want its value.
                    }
                }
我有一个数据表,其结构为(“TableName”、“ColumnNAme1”、“ColumnName2”、“ColumnNAme1处的值”)。对于上面的记录,行类似于(“Property”、“Property”、“Value”、“ARPNOMODIFY”),我想返回值1,因为ARPNOMODIFY存在,它的值是1

现在将另一行视为(“属性”、“属性”、“值”、“ICFAccess”)。现在,若属性表中不存在ICFAGREE属性,那个么我想返回空字符串。 提前谢谢


还考虑另一行(“Admin Excel Unice”、“Actudio”、“条件”、“SetSpecifiedDir”)。现在,在这个示例中,AdminExecuteSequence表有Action和Condition列。Action列下的一个值是“SetSpecifiedDir”,因此其在“Condition”列下的对应值是“ORCADIR”。因此,如果AdminExecuteSequence表中存在“SetSpecifiedDir”值,则我希望返回“ORCADIR”此字符串,否则我将返回null。

有用于检索属性值的API:


编辑:查询是否存在可以使用的表。

DTF有丰富的类来帮助您进行这些类型的测试


由于MSIs中需要某些属性,因此您不应该拥有不包含
属性的数据库。属性表只是一个例子。但有些属性表可能包含arpnodify属性,有些可能不包含。另外,有些MSI包含RemoveFile表,有些MSI不包含。所以,我们需要检查是否存在特定表,以及是否存在特定行。我从datatable(strusture是[“TableName”、“ColumnName1”、“ColumnName2”、“ColumnName1中的值])中获取此特定信息,并希望返回ColumnName2中的值。简而言之,我想将DataTable与msi DataTable连接起来。您是否使用DTF(Microsoft.Deployment.WindowsInstaller)?你似乎是。你是一名C#开发人员吗?如果是,你知道DTF吗?
   using System;
    using Microsoft.Deployment.WindowsInstaller;

    namespace ConsoleApplication1
    {
        class Tester : IDisposable
        {
            Database _database;

            public Tester(string databasePath)
            {
                _database = new Database(databasePath, DatabaseOpenMode.ReadOnly);
            }

            public void Dispose()
            {
                _database.Dispose();
            }

            public bool HasTable(string tableName)
            {
                return _database.Tables.Contains(tableName);
            }

            public bool HasColumn(string tableName, string columnName)
            {
                bool columnExists = false;
                if (HasTable(tableName))
                {
                    columnExists = _database.Tables[tableName].Columns.Contains(columnName);
                }
                return columnExists;
            }


            public bool QueryReturnsData(string sqlStatement, params object[] args)
            {
                return QueryReturnsData(string.Format(sqlStatement, args));
            }

            public bool QueryReturnsData(string sqlStatement)
            {
                bool containsData = false;
                using (View view = _database.OpenView(sqlStatement))
                {
                    view.Execute();
                    using (Record rec = view.Fetch())
                    {
                        if(rec != null )
                        {
                            containsData = true;
                        }
                    }
                }
                return containsData;

            }

        }
    }