简体   繁体   English

C# 到 SQL Server 连接字符串

[英]C# to SQL Server connection string

I'm trying to use this string below in C# to speak to an Visual Studio SQL Server:我正在尝试在 C# 中使用下面的这个字符串来与 Visual Studio SQL Server 对话:

    Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename="C:\Users\Desktop\documents\visual studio 2015\Projects\Latex\Latex\Latex.mdf";Integrated Security=True

The problem is that when I try to debug, etc., it comes up as an error.问题是当我尝试调试等时,它会出现错误。 The database address is the cause, as it is within inverted commas.数据库地址是原因,因为它在引号内。

How do resolve the issue?如何解决问题?

Change the string to either this:将字符串更改为:

"C:\\Users\\Desktop\\documents\\visual studio 2015\\Projects\\Latex\\Latex\\Latex.mdf"

...or this: ...或这个:

@"C:\Users\Desktop\documents\visual studio 2015\Projects\Latex\Latex\Latex.mdf"

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

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