and remote sql server database

How do I add a sql server remote database connection to some code on my computer?
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.

Are you looking to view the remote database in Visual Studio? If so, check out

If you're looking to add a connection string to your code so that your code can access the remote server, check out

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
Ramkisan JagtapLead DeveloperCommented:
Modify your connection string as below :

  <add name="DefaultConnection" providerName="System.Data.SqlClient"
       connectionString="ServerName ,port;Integrated Security=False;User ID=XXXX;Password=XXXX" />
It is same as you do for your local database. You have to provide remote SQL server instance name in connectionstring.
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

You could also add a linked server.
Mandeep SinghDatabase AdministratorCommented:

if sql server box is located on a remote area, then you have to open Port between two machines on which sql server is running.

also make a connection like this.

<?xml version="1.0"?>

      <compilation debug="true" targetFramework="4.5" />
      <httpRuntime targetFramework="4.5" />
    <add name="con" connectionString="Data Source=.;User ID=abc;Password=abc@123;Initial Catalog=AdventureWorks2008R2"/>

michaeldean99Author Commented:
Using ms visual studio express 2013 for Web.
Have added the remote sql sever definition using the server explorer.
I assume that I have to add sql queries to the sql server object explorer?

Sample page
<!DOCTYPE html>
<html xmlns="">
    <title>xxxxxx</title>  etc.

    <table style="width:100%" align="center">.....
How do I add the query results to the code?

Saw that no one has responded yet. There are a bunch of different ways to add database query results to the code.

Some people prefer LINQ (

You can also use data layers. See the YouTube video at starting at around 19:44

Yet another way is using OleDbDataAdapter (

I'd look over those three and choose the one that seems easiest and best for your project.
michaeldean99Author Commented:
Linq seems to be the obvious
Well LINQ to SQL is a bit outdated (would still work though) the Entity Framework has replaced it.
michaeldean99Author Commented:
thanks LordWabbit
Entity Framework looks interesting
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

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.