Click here to Skip to main content
15,914,780 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
database.
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
disc.

Help needed. Thank you.

Best wishes!
Posted
Comments
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    
yes..........

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 http://msdn.microsoft.com/en-us/library/ms165716(SQL.90).aspx[^] 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
 
Comments
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:

http://blogs.msdn.com/b/askjay/archive/2011/10/11/how-can-i-get-a-list-of-installed-sql-server-instances.aspx

http://stackoverflow.com/questions/5301021/how-to-list-the-sql-server-instances-installed-on-a-local-machine-only-local

http://msdn.microsoft.com/en-us/library/a6t1z9x2.aspx
I guess you cannot do this from setup. You have to do it manually or use OSql in batch files.
 
Share this answer
 
Comments
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 :

http://blog.sqlauthority.com/2009/01/05/sql-server-sqlcmd-vs-osql-basic-comparison/

http://msdn.microsoft.com/en-us/library/aa214012(v=sql.80).aspx

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