Hello,
    In my setup program I need to create/attach a SQL Server database as per 
user requirements. If the (database) target location specified by the user 
already contains a database with my DB name, I need to just attach it to SQL 
Server. But, if the target location doesn’t have a file with my DB name, I 
need to install the ‘mdb’ file and then attach it to SQL Server. The code I 
am using is:

    <util:User Id='SQLUser' Name='sa' Password='saPass' />

<Directory Id="DBSAVELOCATION">
    <Component Id='ComponentSqlCreatePDB' 
Guid='D15BCFB5-2041-4CAC-BFB2-10D19C99EE6D'>

    <CreateFolder />

        <File Id='FileTemp' Name='DBTemp.mdf' DiskId='1' Source='MyDB.mdf' 
/>

        <sql:SqlDatabase Id='MYDB' Database='MyDB'
                         User='SQLUser' Server='SQLMC\SQLEXPRESS' 
ConfirmOverwrite='yes'
                         CreateOnInstall='yes' ContinueOnError='no' 
DropOnUninstall='yes'
                         CreateOnReinstall='no'>
          <sql:SqlFileSpec Id='DBPath' Filename='[DBSAVELOCATION]MyDB.mdf' 
Name='MyDB' />
          <sql:SqlLogFileSpec Id='DBLogPath' 
Filename='[DBSAVELOCATION]MyDB_log.ldf' Name='MyDB_log' />
        </sql:SqlDatabase>

      </Component>
</Directory>


where ‘DBSAVELOCATION’ is the path where the user wants to save the 
database. But, the problem is it always tries to create the database 
irrespective of whether it already exists or not. I know I need to use 
‘sql:SqlDatabase’ under the fragment element to just locate it. But, I have 
no idea on how to combine the two aspects (i.e. create (and attach) the 
database if it doesn’t exists and only attach the existing database if it 
already exists).


    Please help me out with this one. Thanks in advance.




Thanking You,
With Regards,

// Sudripta Nandy
S.D.E (Systems Programming),
SARANGSoft Pvt. Ltd. 


------------------------------------------------------------------------------
Master Java SE, Java EE, Eclipse, Spring, Hibernate, JavaScript, jQuery
and much more. Keep your Java skills current with LearnJavaNow -
200+ hours of step-by-step video tutorials by Java experts.
SALE $49.99 this month only -- learn more at:
http://p.sf.net/sfu/learnmore_122612 
_______________________________________________
WiX-users mailing list
WiX-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wix-users

Reply via email to