简体   繁体   English

无法连接到SQL Server DB

[英]Can't connect to SQL Server DB

I'm trying to connect to a DB and I followed the connection string suggestions . 我正在尝试连接到数据库,我按照连接字符串建议 However, I'm not a DB-guy so some things are, hrmp... less than obvious. 但是,我不是一个数据库人,所以有些事情,hrmp ......不太明显。

For instance, the DB server is within the network and the connection to it goes from another server, also in the same network. 例如,数据库服务器位于网络中,与其的连接来自另一台服务器,也位于同一网络中。 I've used the server name and port to connect to it using Management Studio so it's up and running. 我已经使用服务器名称和端口使用Management Studio连接到它,因此它已启动并运行。

This is my connection string. 这是我的连接字符串。

System.Data.SqlClient.SqlConnection conn = new System.Data.SqlClient.SqlConnection();
conn.ConnectionString =
  "integrated security=SSPI;"+
  "server=server.name.as.in.management.studio,4340" +
  "persist security info=False;database=NameOfTheDb";

The authentication is done using AD and the error message is 40 - can't find the server. 使用AD完成身份验证,错误消息为40 - 无法找到服务器。 Besides the obvious - the server can't be found - what can I do to trouble-shoot this, obtain more information etc.? 除了显而易见的 - 无法找到服务器 - 我该怎么做才能解决问题,获取更多信息等?

I'm at a customer and their system is not as well documented as one'd like. 我是一名客户,他们的系统没有人们喜欢的文档。 I get very little information and the coverage is questionable. 我得到的信息非常少,而且报道的内容值得怀疑。 The person who set up the attrocity is gone since a long time. 建立暴行的人已经很久没有了。

Suggestions are welcome. 欢迎提出建议。

EDIT 编辑

Following the corrections provided, I'm getting error code 0 - The requested name is valid but no data of the requested type was found . 在提供更正后,我收到错误代码0 - 请求的名称有效但未找到所请求类型的数据

What do I do with this?! 我该怎么办?! :) :)

System.Data.SqlClient.SqlConnection conn = new System.Data.SqlClient.SqlConnection();
conn.ConnectionString =
"integrated security=SSPI;"+
"Data Source=myServerAddress;" +
"persist security info=False;" +
"Initial Catalog=NameOfTheDb";

Hope this helps. 希望这可以帮助。

Sure servce in Managmnet Sql Server is Start . Managmnet Sql Server中的确保服务是启动 You can do that by go to ---> Control Panel-->All Control Panel Items-->Administrative Tools--Services --> SQL Server(MSSQLSERVER) and click Start . 您可以转到--->控制面板 - >所有控制面板项目 - >管理工具 - 服务 - > SQL Server(MSSQLSERVER),然后单击开始

System.Data.SqlClient.SqlConnection conn = new System.Data.SqlClient.SqlDbConnection();
    conn.ConnectionString =
    "Data Source=ServerName;" +
    "Initial Catalog=DataBaseName;" +
    "User id=UserName;" +
    "Password=Secret;";
    conn.Open();

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

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