How can I use WiX properties in a sql file executed from the installer?

◇◆丶佛笑我妖孽 提交于 2019-12-24 17:22:39

问题


I have a WiX install project that I am rewriting based on our previous installers from Wise. In Wise, you can add files for it to execute (ours used sql script files) and it had a replace tab that specified certain text in the file to be replaced with either with static text or a Wise property.

I am wondering if this is possible in WiX?

Example:

use [SQLDBNAME]
SELECT *
FROM Employee

Where WiX would read the file and replace the [SQLDBNAME] with the value set in WiX's properties table?


回答1:


The Property replacement works for SqlString element, where you define the SQL string literally as a value of the attribute. However, it doesn't work for SqlScript element, where you put the entire SQL script file to Binary. It all depends on how complex is your SQL queries.

When using SqlString, don't forget that SQL uses [ and ] to escape its own reserved words. So you should escape the MSI properties like this in that case: [\[] and [\]].

Hope this helps.



来源:https://stackoverflow.com/questions/3096573/how-can-i-use-wix-properties-in-a-sql-file-executed-from-the-installer

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!