如何连接到远程sql server [英] how to connect to remote sql server

查看:135
本文介绍了如何连接到远程sql server的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

错误



error

A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: SQL Network Interfaces, error: 25 - Connection string is not valid)


    <add name="const" connectionString="Data Source=66.155.58.218:8443;Initial Catalog=Db_col;User Id=sa;Password=puNeCollege02MH12;Integrated Security=True"
      providerName="System.Data.SqlClient" />

推荐答案

确保您的实例名称,用户名和密码已连接。我建议使用Management studio连接远程实例,如果有效则在项目中尝试这些凭据。
Make sure your Instance Name, User Name and password is connect. I would suggest to connect remote instance using Management studio and if it works then try these credentials in your project.


请阅读:

https://www.connectionstrings.com/sqlconnection/ [ ^ ]

此页面提供了大量如何构建正确连接字符串的示例。



您的连接字符串没有任何意义。
Please read this:
https://www.connectionstrings.com/sqlconnection/[^]
This page gives lots of examples how to build a proper connection string.

Your connection string does not make any sense.


使用类似的连接类 -





Use a connection class like-


public SqlConnection dbConnect()
    {
        cnnStr = "Data Source = 10.168.2.32";
        cnnStr += "; Initial Catalog = DBNAME";
        cnnStr += "; Integrated Security = false";
        cnnStr += "; User ID = userid";
        cnnStr += "; Password = password";

        return new SqlConnection(cnnStr);
    }


这篇关于如何连接到远程sql server的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆