简体   繁体   English

与本地db c#Windows窗体一起的连接字符串

[英]connection string in with a local db c# windows forms

I've created a database using Visual Studio 2015 by adding it locally as a mdf file 我已使用Visual Studio 2015创建数据库,方法是在本地将其添加为mdf文件

following this guide: Walkthrough creating a local database SQL Server Express 遵循本指南: 演练创建本地数据库SQL Server Express

The exception that gets thrown is Format of the initialization string does not conform to specification starting at index 81. 引发的异常是Format of the initialization string does not conform to specification starting at index 81.

I'm building a Windows Forms application. 我正在构建Windows窗体应用程序。

My connection string looks like this string cs = @"Data Source=(LocalDB)\\MSSQLLocalDB;AttachDbFilename=|DataDirectory|\\TestDb.mdf;Integrated"; 我的连接字符串看起来像这样的string cs = @"Data Source=(LocalDB)\\MSSQLLocalDB;AttachDbFilename=|DataDirectory|\\TestDb.mdf;Integrated";

You can user Visual Studio's server explorer to connect to your DB and then you'll get the correct connection string: 您可以使用Visual Studio的服务器资源管理器连接到数据库,然后将获得正确的连接字符串:

http://www.c-sharpcorner.com/uploadfile/suthish_nair/how-to-generate-or-find-connection-string-from-visual-studio/ http://www.c-sharpcorner.com/uploadfile/suthish_nair/how-to-generate-or-find-connection-string-from-visual-studio/

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

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