Click here to Skip to main content
15,843,145 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
Hi, there,

I'm working on a web application project which uses SQL Express as
I found I can include SQL Server 2005 Express Edition in the installation
project as Prerequisite,
that's cool.
But I need do more things, I want to change the "Authentication Mode" from
"Windows Authentication mode"
(which is default) to "SQL Server Authentication mode" and assign a "default
password" to user "sa", and
I want to attach a database file which will be include on the installation

Help needed. Thank you.

Best wishes!
Kiran Susarla 17-Dec-12 4:55am    
Are you using Visual Studio Setup and Deployment project to create the installer?
Upniwesh 17-Dec-12 5:03am    

Since you have included SQL as a pre-requisite, if SQL is not available the setup will first install SQL. During SQL Installation you can change SQL Server settings.
In Setup and Deploy project you can write Custom Actions where you can define what needs to be done.
Once the SQL Server is installed and you app binaries are installed you can invoke these custom action and attach the database file using SQL SMO APIs.
Go through this article[^] on how to attach a .mdf file to SQL Express.

The following links may also help you.
Attaching an mdf file to a C# setup project[^]
Share this answer
Upniwesh 17-Dec-12 5:43am    
Thanks for you solution.....
i need to create only one setup for both.
when we install setup than at first will run sql express and and .net also before my application. after that run Commit event of my installer class. in this written code of attach database but their need to server name.
Kiran Susarla 17-Dec-12 5:53am    
You can read from registry the SQL Server instance details. Go through these links:
I guess you cannot do this from setup. You have to do it manually or use OSql in batch files.
Share this answer
Upniwesh 17-Dec-12 5:52am    
i don't have idea about OSql how can i use?
Please help me.
Rahul K Singh 17-Dec-12 6:32am    
Have a glance :

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