简体   繁体   中英

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

您可以使用SQL Express Edition自动附加数据库。

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

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

You should add a Service-Based Database to your project as shown: 在此处输入图片说明 This way you will an app.config setting for automatic Db Attach as well : 在此处输入图片说明
All that you will need to do after that is change the database server instance name.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM