Wednesday, March 7, 2012

Connecting to a remote sql server

Hi,
I have a web application installed on a server. I want to connect to aremote database server. I have access to both the servers, I can assignany user privileges or settings that are needed. How do I do this? Itried it the usual way, specifying the conn string and opening theconn, and expectedly it throwed an sql server does not exists error.
Thanks.
When you say you specifiy the connection string, I'm assuming it's a correct string, but you didn't give us any info about the string - - Are you trying an explicit logon (uid/pwd) or Windows Authentication?
|||I am trying an explicit logon with username and password. The string isthe same one you normally use if you are connecting to a localdatdbase. I just tried changing the server name to the remote servername. Everything else is same.
|||That should work. The format for a local string will work for a remote string - if using SQL Authentication (explicit username and passwords).
The only difference is instead of a local IP (e.g., 127.0.0.1) or server name, use an IP accessiable from your webserver (e.g., 123.123.123.123, or mydatabase.mywebsite.com), whether private or public.
Of course, if you're getting "remote server cannot be found" kind of message, it could be firewall issue. Connecting this way to any SQL Server (local or remote) requires the correct port to open and reachable (default for SQL Server is 1433).
Some things to also keep in mind are the fact that your connection string is being sent over your private or public network (i.e., the internet) unencrypted, and that making open internet connections to SQL Server may require special licensing (as some have suggested).
Hope that helps.
|||Thanks Scott.

No comments:

Post a Comment