简体   繁体   中英

Sql Connection string to my mdf database file

My database.mdf is in the same folder where my application.exe is. I searched other questions and found this way but after I start my program I get an error

屏幕截图

string dbPath = Application.StartupPath + "\\DATABASE1.MDF";

string strConnection = @"Data Source =.\SQLEXPRESS; AttachDbFilename = [" + dbPath + "]; Integrated Security = True; Connect Timeout = 30; User Instance = True";

NVM found soluation . the problem was []

string dbPath = Application.StartupPath + "\\DATABASE1.MDF";
        string strConnection =
            @"Data Source =.\SQLEXPRESS; AttachDbFilename = " + dbPath + "; Integrated Security = True; Connect Timeout = 30; User Instance = True";

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