[英]what is the connection string for this database
I have a database called MyDatabase
exists in sql server 2008 r2
on windows server 2003
我在
windows server 2003
sql server 2008 r2
存在一个名为MyDatabase
的数据库
I want to test my website on that server using Windows Authentication
我想使用
Windows Authentication
在该服务器上测试我的网站
what is the connection string 什么是连接字符串
connectionString="Initial Catalog=MyDatabase;Data Source=localhost;Integrated Security=SSPI;"/>
connectionString =“ Initial Catalog = MyDatabase;数据源= localhost;集成安全性= SSPI;” />
But I don't know if it is correct. 但我不知道这是否正确。 Also, I can't try because I have to give the code to my manager, I need to be everything perfect when I gave them.
另外,我不能尝试,因为我必须将代码提供给我的经理,当我给他们代码时,我需要做到完美。
You can check that by going to Tools->Connect to Database 您可以通过转到工具->连接到数据库来检查
In the Add Connection dialog you'll have your server name and your db name (or add it) and click the Advanced button 在“添加连接”对话框中,您将拥有服务器名称和数据库名称(或添加它),然后单击“ 高级”按钮
In the Advanced Properties dialog copy the string marked below: 在“高级属性”对话框中,复制下面标记的字符串:
This will be your string, in this case: 在这种情况下,这将是您的字符串:
SqlConnection con = new SqlConnection("DataSource=MCA\\LENOVO;Initial Catalog=DecryptTesting;Integrated Security=True");
Make sure you add one more slash "\\" like above or an "@" to a connection. 确保在连接中再加上一个斜线“ \\”或上面的“ @”。 You need to escape the backward slash \\ in your connection string or use the "@" symbol if you want to avoid escaping characters in your string:
如果要避免转义字符串中的字符,则需要在连接字符串中转义反斜杠\\或使用“ @”符号:
SqlConnection con = new SqlConnection(@"DataSource=MCA\LENOVO;Initial Catalog=DecryptTesting;Integrated Security=True");
EDIT: DataSource is the name of your server, Initial Catalog is your database 编辑:数据源是您的服务器的名称,初始目录是您的数据库
Hope this helps 希望这可以帮助
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.