使用C#.net从远程服务的数据库中检索数据 [英] Retrive Data from Database at Remote serve using C# .net
问题描述
我正在使用MS SQL EXPRESS 2008 r2数据库.
我想从存在于另一个系统中但在我的网络中的数据库中检索数据.像S1 pc和S2 pc在网络中连接.使用C#Windows应用程序.我在S2中运行该应用程序,并从S1中存在的数据库中获取数据.
我如何检索数据.什么是连接到S1 pc的数据库的Sqlconnection字符串.如果有人知道,请帮助我.
Hi,
I am using MS SQL EXPRESS 2008 r2 database.
I want to retrieve a data from the database that present in another system but within my network. Like S1 pc and S2 pc are connected in network. using C# windows application. I run the application in S2 and take data from the database that present in S1.
How can i retrieve a data. And what is the Sqlconnection string to connected to S1 pc''s database. If any one knows please help me.
推荐答案
你好
看看这些:
SQL Server连接字符串
创建到远程Sql Server的连接字符串
Hello
Look at these:
SQL Server Connection Strings
Creating a connection String to Remote Sql Server
,您可以使用如下所示的SQL连接字符串
you can use your SQL Connection string as below
string sConStr="Data Source=S1Pc'sIPaddress\\SQLServerInstanceName; initial catalog=yourDBName ; user id= UsrName ; password=Pasword; "
SqlConnection con = new SqlConnection(sConStr);
使用此连接字符串,您可以连接到报表服务器.记住,您必须使用IP地址.
注意:检查您的S1 PC SQL服务器浏览器服务是否已安装并正在运行.并检查您的两个PC防火墙是否都接受通信(为进行检查,您可以禁用两个防火墙)
希望对您有帮助
using this connection sting you can connect to your report server. Remember You must use IP address.
NOTE: check your S1 PC SQL server browser service is install and running. and check your both PC firewall is accept communication (for checking you can disable both firewalls)
i hope this will help you
这篇关于使用C#.net从远程服务的数据库中检索数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!