Click here to Skip to main content
15,908,901 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more: , +
Dear All,

I have a web service as....

C#
[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....
Posted
Updated 10-Jan-12 23:08pm
Comments
anushripatil 11-Jan-12 5:24am    
can you post the error that you are getting ??
anushripatil 11-Jan-12 5:26am    
connectionString="Data Source=*****;Initial Catalog=****;User ID=**;Password=****"
comred 11-Jan-12 5:58am    
Error is like this:
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 - A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.)
comred 11-Jan-12 6:00am    
**** showing that it contains value but I cant mention here... you can consider any string right??

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;


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.
 
Share this answer
 
 
Share this answer
 
Any Expert Comments???? Please....
 
Share this answer
 
My FTP server is not here its in USA... and I my Database is in India.. So my .aspx and .asmx files are on ftp. The web service is trying to retrieve data from from database server. and in that scene I am getting the 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: TCP Provider, error: 0 - A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.)
 
Share this answer
 
Comments
Rajesh Anuhya 12-Jan-12 1:41am    
Post your comments under your Question
comred 12-Jan-12 2:36am    
:P

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900