Install sql server database with my c # application

I wrote a C # application that uses a SQL Server database. The intended users of this program will be running SQL Server 2008 R2. I created an installer (deployment project in visual studio) that installs my program, but I would also like to install it. How can i do this?

+5
source share
5 answers

You can write your own action for installation. Take a look at the following article .

+2
source

, SQL Server 2008. , , . SQL Setup . SQL Server, SQL Server Compact.

SQL Server 2005+, . , SQL- SA. % db_name% .

IF NOT EXISTS (SELECT name FROM master.dbo.sysdatabases WHERE name = N'%db_name%')
BEGIN
DECLARE @data_path nvarchar(1024), @db_path nvarchar(1024), @log_path nvarchar(1024)
EXEC master.dbo.xp_instance_regread N'HKEY_LOCAL_MACHINE', N'Software\Microsoft\Microsoft SQL Server\Setup', N'SQLDataRoot', @data_path OUTPUT    
SET @db_path = @data_path + N'\Data\%db_name%_Data.MDF';
SET @log_path = @data_path + N'\Data\%db_name%_log.ldf';
EXECUTE (N'
    CREATE DATABASE [%db_name%]  ON (NAME = N''%db_name%_Data'', 
     FILENAME = N''' + @db_path  + N''',
     SIZE = 3, FILEGROWTH = 10%) LOG ON (NAME = N''%db_name%_Log'',
     FILENAME = N''' + @log_path + N''',
     SIZE = 3, FILEGROWTH = 10%)
     COLLATE SQL_Latin1_General_CP1_CI_AS')
END
+2

. proj_deploy, (proj_deploy) , VS 2008/2010, , , - .

- , ..

+2

. , , , msi , .exe, MSI. .

http://wix.mindcapers.com/wiki/Bootstrapper , .

0

/, SQL Server , .

If this is a single-user database application, I would recommend using SQL Server Compact. Then "installation" consists only of copying some DLLs.

0
source

All Articles