Question

I'm trying to have WIX create a database in a location the user specifies. I've got it working for the most part using some CustomActions and passing parameters to a sql script. But am having problems with permissions on the directory I'm attempting to create the DB in.

Searching for a resolution to this problem lead me to a post on here that I had not seen before today (Wix: create a sql server database at a specified location) where it seems like someone accomplished the same thing I'm wanting to do.

It is not clear from that post how the user was invoking the script? I am hoping they were doing something like the code code snippet below and I just don't know how to pass values to the script. If so, that would greatly simplify my task.

<sql:SqlDatabase>
  <sql:SqlScript>
</sql:SqlDatabase

Can someone tell me how to pass values to a SqlScript when not using a customAction to invoke the script via sqlcmd.exe?

Thanks.

Était-ce utile?

La solution

For the future reference of anyone else wishing to do this there are a couple of ways to create a database at a specified location. The simplest of which is using the wix tags that I did not know existed:

<sql:SqlFileSpec Name="DataBaseFile"  Id ="mdfFile" Filename = "[DBDIR]TestDataBase.mdf"/>
<sql:SqlLogFileSpec Name="DataBaseLogFile" Id ="ldfFile" Filename = "[DBDIR]TestDataBase_Log.ldf"/>

This works perfectly as long as the directory that the database is being created in is not under "Program Files" or "Program Files (x86)". Both of these locations seem to have special permissions to them that don't allow SQL Server to create a database there. This theory can be tested by trying to create a database using Sql Server Mgmt Studio in a folder somewhere under Program Files and looking at the error that is produced. Which is something like this for me:

CREATE FILE encountered operating system error 5(Access is denied.) while attempting to open or create the physical file

I'm still trying to figure out how an installer can accomplish putting a database under Program Files as I'm sure it's been done before.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top