Click here to Skip to main content
15,889,830 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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
C#
m_cnADONetConnection.ConnectionString =
"Server=113.30.141.10;" +
 Database=CorporateDatabase1;" +
 "User id=sa;Password= whatever is password )";
 m_cnADONetConnection.Open();

it gives error as

HTML
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)"; 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..
Posted
Updated 27-Sep-12 1:24am
v3

change your conn string as:
C#
Data Source=113.30.141.10;Initial Catalog= CorporateDatabase1;User Id=sa;
Password=myPassword;
 
Share this answer
 
Comments
16041984 27-Sep-12 4:48am    
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)
Kuthuparakkal 27-Sep-12 4:52am    
Why do you include port into ip address of server, it's wrong. Port should be added to intitial catalog(DB Name)
m_cnADONetConnection.ConnectionString =
"Server=113.30.141.10;" +
"Database=CorporateDatabase1,1433;" +
"Integrated Security=false;" +
"Connect Timeout=30;" +
"User id=sa;Password=password)";
16041984 27-Sep-12 5:08am    
if i exclude port number but still it gives error as i mentioned above.
any help......management studio is not installed in my pc.i first made tables in remote server and in connection string i access remote database
16041984 28-Sep-12 1:43am    
waiting for ur reply sir
Faizan Mubashar 19-Dec-13 0:27am    
http://www.connectionstrings.com/sql-server-2008/
See this link
http://www.connectionstrings.com/sql-server-2008/
See this link
 
Share this answer
 

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