Hi Tim, 

thanks for a code example, I allowed to use this example in my scenario and
it works perfect, but it doesn't delete database files and directory when
uninstall. I want to delete database files after uninstall. This is code:

...
<Directory Id="Data" Name="Data">
        <Component Id="DemoDbComponent"
Guid="c57c91e1-d185-49c1-91f9-fc41a26298a3">                            
                <CreateFolder>
                        <Permission User="Administrators" GenericAll="yes" /> 
                        <Permission User="NT AUTHORITY\NetworkService" 
GenericAll="yes" />
                        <Permission User="Everyone" GenericAll="yes" /> 
                </CreateFolder> 
                <File Id="DemoMDF" Name="Demo.mdf" Source="Demo.mdf" 
KeyPath="yes"/>                                                                 
                                                                                
   
                <sql:SqlString Sequence="1" SqlDb="DB1"  
ExecuteOnUninstall="yes"
Id="DropUserId" SQL="USE [\[][DBNAME][\]];DROP LOGIN
                        [USERIDVALUE];DROP USER [USERIDVALUE]" 
ContinueOnError="no"/>
                <sql:SqlString Sequence="2" SqlDb="DB1"  
ExecuteOnUninstall="yes"
Id="DetachDb" SQL="sp_detach_db [\[][DBNAME][\]], true, false"
ContinueOnError="yes"/>
                <sql:SqlString Sequence="3" SqlDb="DB1"  RollbackOnInstall="yes"
Id="RollbackDb" SQL="USE [\[][DBNAME][\]];DROP LOGIN
                        [USERIDVALUE];DROP USER [USERIDVALUE];DROP DATABASE 
[\[][DBNAME][\]]"
ContinueOnError="no"/>
                <sql:SqlString Sequence="4" SqlDb="DB1"  ExecuteOnInstall="yes"
Id="AttachDb" SQL="CREATE DATABASE [\[][DBNAME][\]] ON
                        (FILENAME=N'[#DemoMDF]') FOR ATTACH" 
ContinueOnError="no"/>
                <sql:SqlString Sequence="5" SqlDb="DB1"  ExecuteOnInstall="yes"
Id="CreateUserId" SQL="IF NOT EXISTS ( SELECT * FROM
                        sys.server_principals WHERE name = N'[USERIDVALUE]' ) 
CREATE LOGIN
                        [USERIDVALUE] WITH PASSWORD='[PWDVALUE]', 
DEFAULT_DATABASE=[DBNAME],
                        CHECK_POLICY=OFF;USE [DBNAME];IF EXISTS(SELECT name 
FROM sys.sysusers
                        WHERE name=N'[USERIDVALUE]')DROP USER 
[USERIDVALUE];CREATE USER
                        [USERIDVALUE];EXEC sp_addrolemember db_owner, 
[USERIDVALUE];"
ContinueOnError="no"/>                                                          
                                                                                
        </Component>                                                            
</Directory>                            
...
<Fragment>
        <sql:SqlDatabase Id="DB1" Database="master" Server='[SQLSERVER]'
></sql:SqlDatabase>
</Fragment>     
...

When I uninstall, everything(files, directories) is deleted, but this one
directory(Data) and database files(demo.mdf/ldf) are not deleted. In the msi
uninstall log are no information, which can help me find out, why this files
are not deleted.

thanks





Tim Fisher wrote:
> 
> Yes, you're right it does. Ok, your suggestions worked. Now my SQL
> scripts run correctly. Thank you!
> 
> One thing to note is that if I tried to use ExecuteOnInstall in the
> same element with a RollbackOnUninstall, then it doesn't get executed
> at all (undocumented).
> 
> Anyway I have a new problem, during uninstall. Is there a way to
> install these files normally, but leave them alone on uninstall?
> (Since they may now contain user data.)
> 
> Here's my code now:
> 
> <Directory Id="DbDataDir" Name="DATA">
>       <Component Id="CmpntBaselineDb"
> Guid="c57c91e1-d185-49c1-91f9-fc41a26298a3">
>               <File Id="MDF" Name="Baseline.mdf" Source="Baseline.mdf" 
> KeyPath="yes"
> />
>               <File Id="LDF" Name="Baseline_log.ldf" 
> Source="Baseline_log.ldf" />
>               <sql:SqlString Sequence="1" SqlDb="DB1" ExecuteOnUninstall="yes"
> Id="DropUserId" SQL="USE [\[][DBNAME][\]];DROP LOGIN
> [USERIDVALUE];DROP USER [USERIDVALUE]" ContinueOnError ="yes" />
>               <sql:SqlString Sequence="2" SqlDb="DB1" ExecuteOnUninstall="yes"
> Id="DetachDb" SQL="sp_detach_db [\[][DBNAME][\]], true, false"
> ContinueOnError="yes" />
>               <sql:SqlString Sequence="3" SqlDb="DB1" RollbackOnInstall="yes"
> Id="RollbackDb" SQL="USE [\[][DBNAME][\]];DROP LOGIN
> [USERIDVALUE];DROP USER [USERIDVALUE];DROP DATABASE [\[][DBNAME][\]]"
> ContinueOnError="yes" />
>               <sql:SqlString Sequence="4" SqlDb="DB1" ExecuteOnInstall="yes"
> Id="AttachDb" SQL="CREATE DATABASE [\[][DBNAME][\]] ON
> (FILENAME=N'[#MDF]') FOR ATTACH" ContinueOnError="yes" />
>               <sql:SqlString Sequence="5" SqlDb="DB1" ExecuteOnInstall="yes"
> Id="CreateUserId" SQL="IF NOT EXISTS ( SELECT * FROM
> sys.server_principals WHERE name = N'[USERIDVALUE]' ) CREATE LOGIN
> [USERIDVALUE] WITH PASSWORD='[PWDVALUE]', DEFAULT_DATABASE=[DBNAME],
> CHECK_POLICY=OFF;USE [DBNAME];IF EXISTS(SELECT name FROM sys.sysusers
> WHERE name=N'[USERIDVALUE]')DROP USER [USERIDVALUE];CREATE USER
> [USERIDVALUE];EXEC sp_addrolemember db_owner, [USERIDVALUE];"
> ContinueOnError="yes" />
>       </Component>
> </Directory>
> 
> Tim
> 
> On Fri, Jun 13, 2008 at 2:55 PM, Rob Mensching
> <[EMAIL PROTECTED]> wrote:
>> We're working on getting the WiX v3 documentation up there.  However,
>> every download of the WiX toolset includes an up to date (as much as we
>> have it) version of the WiX.chm.  That should contain all the
>> information...
>>
> 
> -------------------------------------------------------------------------
> Check out the new SourceForge.net Marketplace.
> It's the best place to buy or sell services for
> just about anything Open Source.
> http://sourceforge.net/services/buy/index.php
> _______________________________________________
> WiX-users mailing list
> WiX-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/wix-users
> 
> 

-- 
View this message in context: 
http://n2.nabble.com/Attach-a-database-tp712370p724565.html
Sent from the wix-users mailing list archive at Nabble.com.


-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
WiX-users mailing list
WiX-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wix-users

Reply via email to