Skip to content

Commit

Permalink
Fixes issue 50. Lists only tables that actually exist in the msi.
Browse files Browse the repository at this point in the history
  • Loading branch information
activescott committed Aug 1, 2013
1 parent baf4085 commit aa44dd7
Showing 1 changed file with 47 additions and 3 deletions.
50 changes: 47 additions & 3 deletions src/LessMsi/UI/MainFormPresenter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
// Scott Willeke ([email protected])
//
using System;
using System.Collections.Generic;
using System.Linq;
using LessMsi.Msi;
using LessMsi.UI.Model;
using Misc.Windows.Forms;
Expand Down Expand Up @@ -171,7 +173,7 @@ public void Status(string text)

public void LoadTables()
{
var msiTableNames = new object[]
var allTableNames = new string[]
{
#region Hard Coded Table Names
//FYI: This list is from http://msdn.microsoft.com/en-us/library/2k3te2cs%28VS.100%29.aspx
Expand Down Expand Up @@ -279,9 +281,51 @@ public void LoadTables()
"Upgrade"
#endregion
};

var systemTables = new string[]
{
"_Validation",
"_Columns",
"_Streams",
"_Storages",
"_Tables",
"_TransformView Table"
};

IEnumerable<string> msiTableNames = allTableNames;

using (var msidb = new Database(View.SelectedMsiFile.FullName, OpenDatabase.ReadOnly))
{
using (new DisposableCursor(View))
{
try
{
Status("Loading list of tables...");
var query = "SELECT * FROM `_Tables`";
using (var msiTable = new ViewWrapper(msidb.OpenExecuteView(query)))
{
var tableNames = from record in msiTable.Records
select record[0] as string;
//NOTE: system tables are not usually in the _Tables table.
var tempList = tableNames.ToList();
tempList.AddRange(systemTables);
msiTableNames = tempList.ToArray();
}

Status("");
}
catch (Exception e)
{
Status(e.Message);
}

View.cboTable.Items.Clear();
View.cboTable.Items.AddRange(msiTableNames.ToArray());
View.cboTable.SelectedIndex = 0;
}
}

View.cboTable.Items.Clear();
View.cboTable.Items.AddRange(msiTableNames);

}

/// <summary>
Expand Down

0 comments on commit aa44dd7

Please sign in to comment.