Dr. Rajesh Rolen
Dr. Rajesh Rolen

Reputation: 14285

Automatically attach SQL Server database during/after installation

Please tell me how can we attach SQL Server database (SQL Server 2005) during installation or after installation using c#.net (desktop application). We can create a form to get details of connection string (user id, pass, server name etc..) . please tell me how can we automatically attach database with SQL Server using .net

Upvotes: 1

Views: 2460

Answers (3)

basarat
basarat

Reputation: 276383

You should add a Service-Based Database to your project as shown: enter image description here This way you will an app.config setting for automatic Db Attach as well : enter image description here
All that you will need to do after that is change the database server instance name.

Upvotes: 1

Govind Malviya
Govind Malviya

Reputation: 13763

You can use the SQL Express Edition it attach automatically database.

Upvotes: 3

IsmailS
IsmailS

Reputation: 10863

Execute a full create database script with your tables, SPs etc. the same way you do any insert i.e. call ExecuteNonQuery method.

Is it what you were asking or you need something more?

Upvotes: 2

Related Questions