简体   繁体   中英

how to run a query in c# windows form application without sql connection

I want to attach my database to my server at the start of my application so stil i don't have any connection to server i should run this code at first

CREATE DATABASE LibraryDB ON 
(FILENAME = 'E:\++Projects\Visual Studio 2017\Library\Library\bin\Debug\LibraryDB.mdf'),
(FILENAME = 'E:\++Projects\Visual Studio 2017\Library\Library\bin\Debug\LibraryDB_log.ldf')
FOR ATTACH;

How can I run this code or this query in my program?

只需连接到master数据库?

SqlConnection myConn = new SqlConnection ("Server=<Your Server>;Integrated security=SSPI;database=master");

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