UPDATE:
While the answers below work as alternative solutions, I would like to mention that my original method really works. After looking at the answers below, I found out that my call to Session.Log () actually deleted [...] when it was sent to the log file. The square brackets remained in my SQL as I fed it into the SQLCommand object. My problem was that SQL (of which I only posted the first few lines) had "GO in it" which are not SQL commands. As soon as I solved this problem, it worked :)
* (Reminder, as much information as possible, is always useful: D)
On Wix, I have SQL files stored in binary elements
<Binary Id="SQLStep1" SourceFile="SourceDir\Step1_SQL_Build.sql"></Binary> <Binary Id="SQLStep2a" SourceFile="SourceDir\Step2a_SQL_Build.sql"></Binary> <Binary Id="SQLStep2b" SourceFile="SourceDir\Step2b_SQL_Build_sp_iv6Login.sql"></Binary> <Binary Id="SQLStep2c" SourceFile="SourceDir\Step2c_SQL_Grant.sql"></Binary>
Then I use a custom action to pull sql from the binary table, and string to replace the database name (provided by the text box in the installer)
private static string ReplaceDBName(Session session, string binaryKeyName) { View v = session.Database.OpenView("SELECT Data FROM Binary WHERE Name = '{0}'", binaryKeyName); v.Execute(); Record r = v.Fetch(); using (StreamReader reader = new StreamReader(r.GetStream("Data"))) { string text = reader.ReadToEnd(); text = text.Replace(@"DB_NAME", session["DATABASE_NAME"]); session.Log("Running SQL: " + text); return text; } }
An example SQL statement is as follows:
USE [master] GO CREATE DATABASE [DB_NAME] COLLATE SQL_Latin1_General_CP1_CI_AS GO
However, the row that I exit from the βBinaryβ table seems to pull out all the [...] content, such as WiX Properties, so I stayed with
USE GO CREATE DATABASE COLLATE SQL_Latin1_General_CP1_CI_AS GO
Is there a flag that I can set to make WiX not think that SQL syntax is WiX properties?