使用Visual C#连接到远程SQL数据库 [英] Connect to remote SQL database with Visual C#

查看:58
本文介绍了使用Visual C#连接到远程SQL数据库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有ac#program并想将它连接到远程sql server(另一台机器上的sql server)

我需要c#程序里面的连接字符串的帮助。

i给连接字符串

I have a c# program and want to connect it to remote sql server (sql server on another machine)
and i need help with the connection string inside the c# program.
i give connection string as

m_cnADONetConnection.ConnectionString =
"Server=113.30.141.10;" +
 Database=CorporateDatabase1;" +
 "User id=sa;Password= whatever is password )";
 m_cnADONetConnection.Open();



它给出错误




it gives error as

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: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server)





m_cnADONetConnection.ConnectionString =Server = 113.30.141.10:1433;+Database = CorporateDatabase1;+Integrated Security = false;+Connect Timeout = 30;+User id = sa; Password = password);但它会出错,因为错误是在建立与SQL Server的连接时发生与网络相关或特定于实例的错误。服务器未找到或无法访问。验证实例名称是否正确,以及SQL Server是否配置为允许远程连接。 (提供者:命名管道提供程序,错误:40 - 无法打开与SQL Server的连接)

任何帮助..



m_cnADONetConnection.ConnectionString = "Server=113.30.141.10:1433;" + "Database=CorporateDatabase1;" + "Integrated Security=false;" + "Connect Timeout=30;" + "User id=sa;Password=password)"; but it gives error as Error is 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: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server)
any help..

推荐答案

更改您的conn字符串为:
change your conn string as:
Data Source=113.30.141.10;Initial Catalog= CorporateDatabase1;User Id=sa;
Password=myPassword;


http://www.connectionstrings.com/sql-server-2008/

请参阅此链接
http://www.connectionstrings.com/sql-server-2008/
See this link


这篇关于使用Visual C#连接到远程SQL数据库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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