访问远程数据库 [英] Accessing Remote Database

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

问题描述

亲爱的所有人,

我有一个Web服务....

Dear All,

I have a web service as....

[WebMethod]
 public DataTable DataShow()
    {
        SqlConnection cn = new SqlConnection("Server=xxx.xxx.xxx.xxx;Network Library=DBMSSOCN;Initial Catalog=xxx;uid=xxx;pwd=xxxxxxxx");
        SqlDataAdapter da = new SqlDataAdapter("Select * from xxxx", cn);
        DataSet ds = new DataSet();
        da.Fill(ds, "xxxxx");
        DataTable dt = ds.Tables[0];
        return dt;

    }



如您所见,它将返回一个数据表..但是在这里,我要处理的数据库服务器对我来说不是本地的,它位于远程位置.因此,我无法与之建立联系.
我要从该服务器检索数据该怎么做,我知道该服务器的用户名和密码.我的连接字符串正确吗?请帮帮我.

谢谢....



As you see it will return me a data table.. But here I am dealing with the Database server which is not local to me, Its on remote location. Because of it I am not able to connect with it.
What should I do for retrieving data from that server, I know the username and password of that server. Is my connection string correct. Please help me out.

thanks....

推荐答案

使用下面的连接字符串连接到远程sql服务器db
Use the below connection string to connect to your remote sql server db
Data Source=190.190.200.100,1433;Network Library=DBMSSOCN;Initial Catalog=myDataBase;User ID=myUsername;Password=myPassword;



在这里
远程Sql Server公共IP:190.190.200.100
远程Sql服务器端口号:1433

**确保您的SSMS是否已连接到此远程服务器.



Here
Remote Sql Server Public IP: 190.190.200.100
Remote Sql server Port number : 1433

** make sure that your SSMS is connecting to this remote server or not.


这可能对您有帮助-

http://www.connectionstrings.com/sql-server-2008 [
This may help you-

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


任何专家评论???请....
Any Expert Comments???? Please....


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

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