简体   繁体   English

SQL连接字符串到我的mdf数据库文件

[英]Sql Connection string to my mdf database file

My database.mdf is in the same folder where my application.exe is. 我的database.mdf与我的application.exe位于同一文件夹中。 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 . NVM找到了解决方法。 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";

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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