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?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

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
tobzzzCommented:
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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
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
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft SQL Server 2005

From novice to tech pro — start learning today.