使用连接字符串错误的IP地址 [英] IP address using connection string error

查看:86
本文介绍了使用连接字符串错误的IP地址的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在客户端系统中连接sql server但是..



我有一个错误,如



i want to connect sql server in client system but..

i have an error like

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: TCP Provider, error: 0 - No connection could be made because the target machine actively refused it.)





web.config





web.config

<configuration>
    <configSections>
    </configSections>
    <connectionStrings>
        <!--<add name="ConnectionString" connectionString="Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\demo.mdf;Integrated Security=True;User Instance=True" providerName="System.Data.SqlClient"/>-->
      <add name="ConnectionString" connectionString="Data Source=192.168.0.82,1433;Network Library=DBMSSOCN;Initial Catalog=NewsAdvt;User ID=sa;Password=sql;" providerName="System.Data.SqlClient"/>
    </connectionStrings>
<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/></startup></configuration>





表格代码





Form Code

db = DatabaseFactory.CreateDatabase("Connectionstring");
           dbCommand = db.GetSqlStringCommand("select max(GroupCode) from AccountGroup");
           DataSet ds = db.ExecuteDataSet(dbCommand);





错误行是 DataSet ds = db.ExecuteDataSet(dbCommand);



我找不到错误,我该怎么办?





问候

AR



error line is DataSet ds = db.ExecuteDataSet(dbCommand);

I can't find the error, what can i do ?


Regards
AR

推荐答案

在本地计算机上安装MS SQL Server时,其实例(默认情况下)仅在本地计算机上可见。如果要在LAN中使用MS SQL Server,则需要启用TCP / IP连接。

请阅读:启用对SQL Server Express的网络访问 [ ^ ]



如果赢了'请帮助,请尝试通过实例连接到MS SQL Server:

When you install MS SQL Server on local machine, its instance (by default) is visible on local computer only. If you want to use MS SQL Server in LAN, you need to enable TCP/IP connections.
Please, read this: Enabling Network Access to SQL Server Express[^]

If it won't help, please try to connect to MS SQL Server via instance:
Server=myServerName\myInstanceName;Database=myDataBase;User Id=myUsername;
Password=myPassword;

而不是IP地址。

http ://www.connectionstrings.com/sql-server/ [ ^ ]

instead of IP address.
http://www.connectionstrings.com/sql-server/[^]


我的错误是服务器计算机和客户端计算机中的手动问题,可能是配置管理器 - > tcp\ip设置为启用和协议启用...





my mistake is the manual problem in server computer and client computer that is may be the configuration manger -> tcp\ip set as enable and protocol as enable...


<connectionstrings>
   <add name="ConnectionString" connectionstring="Data Source=192.168.0.82,1433;Network Library=DBMSSOCN;Initial Catalog=NewsAdvt;User ID=sa;Password=sql;" providername="System.Data.SqlClient" />
 </connectionstrings>
 <startup uselegacyv2runtimeactivationpolicy="true">
   <supportedruntime version="v4.0" sku=".NETFramework,Version=v4.0" />
 </startup>


这篇关于使用连接字符串错误的IP地址的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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