Kae Travis

Handling tables that don’t exist in an MSI database

This blog entry provides an example of handling tables that don’t exist in an MSI database using VBScript. It follows on from the previous blog post which provided a tutorial on inserting a registry value in an MSI database using the Modify method and VBScript.

It forms part 10 of an 17-part series that explores how to use VBScript to manipulate MSI relational databases using the Windows Installer API. Throughout this series of tutorials, we identify the common issues that we encounter and the best practises that we use to overcome them.

If the Registry table doesn’t exist when we run the script above, we will get a nasty error saying: Msi API Error: OpenView,Sql.

However, we can handle this error by checking if a table exists in the first place! To do this, we read the TablePersistent property of the database object and pass in the name of the table as an argument:

'check if Registry table exists (0 is a temporary table, 1 is a permanent table)
If oDatabase.TablePersistent("Registry") = 1 Then
'create a view of the registry we want to see
Dim sql : sql = "SELECT `Key` FROM `Registry`"
Dim regView : Set regView = oDatabase.OpenView(sql)
....
....
....
regView.Close
Set regView = Nothing
End If

Thanks for reading on handling tables that don’t exist in an MSI database using VBScript. Next you can find out how to use inner joins when reading from an MSI database using VBScript.

Handling tables that don’t exist in an MSI database
Handling tables that don’t exist in an MSI database

Leave a Reply