-
-
Notifications
You must be signed in to change notification settings - Fork 152
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixes issue 50. Lists only tables that actually exist in the msi.
- Loading branch information
1 parent
baf4085
commit aa44dd7
Showing
1 changed file
with
47 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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; | ||
|
@@ -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 | ||
|
@@ -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> | ||
|