cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Highlighted
Not applicable

Query SQL database from IS

Hello,

I got into the following problem:

A Basic MSI project with SQL scripts accessing an existing SQL Server database.

I want to update a value (table.field) in the db, but before I'd like to query it for the existing value and display it to the user.

So, from a SQL script is it possible to return a value into a IS variable?

If not (like it looks like :confused: ), is there any other solution (except sqlcmd command line)?

Thanks,
Ioan
Labels (1)
0 Kudos
4 Replies
Highlighted
Cygnusx1
Flexera beginner

Re: Query SQL database from IS

something like this in a vbscript CA will retrieve the UpgradeCode into the MYPROPERTY property:

Const sPC = "{ProductCode of installed software}"
Dim CachedMSI
Set oInstaller = CreateObject("WindowsInstaller.Installer")
For Each msiProduct In oInstaller.Products
If UCase(msiProduct) = sPC Then
CachedMSI = oInstaller.ProductInfo(msiProduct, "LocalPackage")
Exit For
End If
Next

Set oDB = oInstaller.OpenDatabase(CachedMSI, 1)
Set View = oDB.OpenView"SELECT `Value` FROM `Property` WHERE `Property` = 'UpgradeCode'")
View.Execute
Set Record = View.Fetch
Property("MYPROPERTY") = oRecord.StringData(1)
View.Close
0 Kudos
Highlighted
Not applicable

Re: Query SQL database from IS

Sorry, this is not what I meant.

I'm talking about a SQL Server database.

I can create a SQL script to be run against it and do some updates, inserts, etc. But I want to retrieve a field value:

SELECT Field1 FROM aTable WHERE condition

and to pass the Field1 value to a MSI property.
0 Kudos
Highlighted
Not applicable

Re: Query SQL database from IS

So nobody tried to query a SQL database? :confused:
0 Kudos
Highlighted
mano_n_s75
Pilgrim

Re: Query SQL database from IS

i am not sure that your requirement can be addressed straight away using the SQL script view, but what you can do it use install script to create a CA that will make a connection and try to query the DB for the required vaue.
0 Kudos