Click here to Skip to main content
15,861,168 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more: (untagged)
hi
I am building a setup for my application using wix3.8 tool set in Visual studio 2010.
i want to attach a database to the sql server 2005 using sqlstring element.
Here is the XML code that I am using

XML
<Component Id='SqlComponent' Guid='807399d3-D8C7-4102-BA84-9702188FA316'>

       <sql:SqlString ContinueOnError='yes' Id='Attachdb' ExecuteOnInstall='yes' SqlDb="master" SQL="'CREATE DATABASE NCInventory ON PRIMARY
                                                                                 (FILENAME =       'D:\DB2\NCInventory.mdf'),
                                                                                 (FILENAME =       'D:\DB2\NCInventory_1.ldf')
                                                                                 for attach go'"/>

     </Component>


Now when i compile the setup i get the following error

Unresolved reference to symbol 'SqlDatabase:master' in section Fragment.
Another issue is that how to specify the sql server instance to which I
want to attach the database files.
Please do not get struck with the .mdf files path. it is just an example.

Any kind of help or suggestion will be appreciated.
Posted
Updated 12-Oct-14 20:12pm
v2

1 solution

You should create a separate sqlDatabase element in your Component xml definition, something like:
XML
<sql:sqldatabase id="masterId" database="master" server="[SQLSERVERNAME]" xmlns:sql="#unknown" />

This is in case of Windows authentication. For SQL auth you need to add User element to SqlDatabase element. Then in your SqlString reference your masterId

XML
<sql:sqlstring id="Attachdb" executeoninstall="yes" sqldb="masterId" xmlns:sql="#unknown" /> 
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900