We’re moving our forums to a new platform.

You can still browse and search existing topics, but you can no longer create new topics or post replies.

For questions, technical issues, or feature requests, please don’t hesitate to contact our support team at support@advancedinstaller.com.

Thank you for your understanding!

WesCutting
Posts: 14
Joined: Wed Jul 23, 2014 5:07 pm

Creating a SQL Database and attaching a .MDF

I'm currently attempting to create a database and attach a .mdf in an existing SQL Server instance on the target machine. Previously, using WIX, I would target the master DB in the SQL Server instance and run a CREATE DATABASE statement with the appropriate file for attachment. In Advanced Installer I created a Predefined Connection with the Server property set to a User Defined Install Parameter Property named SQLSERVERINSTANCE and created a script with the same CREATE DATABASE statement. SQLSERVERINSTANCE is made of two other properties as such: [|SQLDBSERVER]\[|SQLDBINSTANCE], I want the value to read something like ComputerName\SQLEXPRESS as an example. How do I set the SQLDBSERVER property as the target machine's name? I have tried several different approaches, including creating another property named COMPUTERURI, having a custom action set that property to the OS ComputerName variable then point SQLDBSERVER to COMPUTERURI. This was the approach I found here: http://www.advancedinstaller.com/forums ... f=2&t=8291 It's not an identical case but was the closest thing I could find.

Or if I'm going about this in the entirely wrong fashion how best should I proceed to create a database and attach the .mdf?

Thank you in advance for any and all input :)
Daniel
Posts: 8283
Joined: Mon Apr 02, 2012 1:11 pm
Contact: Website

Re: Creating a SQL Database and attaching a .MDF

Hello and welcome to Advanced Installer forums,

Thank you for your interest in Advanced Installer.

You can access the computer name by using the "ComputerName" Windows Installer property. Also, please keep in mind that by referring an installer property like this: [|SQLDBSERVER], then this pseudo-formatted reference will be resolved at build time. If you want a property reference to be resolved at install time, then you should refer your property using a formatted reference (e.g. [SQLDBSERVER]).

Also, in order to set your "SQLSERVERINSTANCE" property you can use the approach debated in our "Browse for SQL Servers" how to.

If you have any question just let us know.

All the best,
Daniel
Daniel Radu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube

Return to “Building Installers”