Need to connect to a SQL server database hosted on another server

Hello,

I need to produce a web site in ASP hosted on my own Windows 2003 server. The problem is I need to have read access to a SQL server database that is hosted on another external web server. I need to know how to set up the connection string and what the IT people need to do to enable my script to access the database.

Thanks
mike99cAsked:
Who is Participating?
 
tobzzzConnect With a Mentor Commented:
whoops, forget the quote marks around the connection, should look like the below, just make it into a tests.asp page anywhere offline and run it with your servers IP and what I said above
<%
Set conn=Server.CreateObject("ADODB.Connection")
conn.Open("driver={SQL Server}; server=000.111.222.333,0000; database=databaseName; User ID=sa; password='yourPassword'")
'   do lookups etc here
conn.Close
Set conn = Nothing
%>

Open in new window

0
 
tobzzzCommented:
From my machine at home using code like this I can access an MS SQL Server across the world:
<%
Set conn = Server.CreateObject("ADODB.Connection")
conn.Open(driver={SQL Server}; server=000.111.222.333,0000; database=databaseName; User ID=sa; password='yourPassword')
'   do ya lookups etc here
conn.Close
Set conn = Nothing
%>

all you need is the IP and sometimes port (the bit after the comma), your database name, user id and password.
0
 
mike99cAuthor Commented:
Great thanks for this. I will test this out then get back to you.

Before I do so I noticed the following:
server=000.111.222.333,0000;

What is the ",0000" at the end for? Is this some kind of bit mask?
0
 
tobzzzCommented:
that's the port as is just something I'm using with a remote server, it may simply be an IP address for you. Perhaps in your hosting control panel it offers you their "path"? If not you probably have to ask them for it because of course it will be different from your home to being on their local server! I hope that makes sense.

p.s. I *think* the last four digits are the port number, I can't think what else they would be.
0
 
BrandonGalderisiCommented:
The ,#### in the server is the port number.  In the event that you are attaching to an instance, your server path may be {server}\{InstanceName}.  But if you specify a port number (such as the default of 1433) it will ALWAYS go to that port number and not necessarily the named instance specified.  To avoid this, do not use the port number unless told to.  
0
All Courses

From novice to tech pro — start learning today.