Connection string for SQL Server Express on remote computer?

11,719

Solution 1

You've used the connection string attribute:

DataSource

There is no such thing, and I suspect it was just a typo (it pays to use cut and paste instead of transcribing). There is actually a space in that attribute, so it should be:

Data Source

Solution 2

Here is a list of things you need to check on the other computer:

  • Is TCP/IP protocol enabled? Go to SQL Server Configuration Manager -> SQL Server Network Configuration -> Protocols for {instance}
  • What IP addresses are enabled for listening in configuration manager? Go to TCP/IP properties -> IP Addresses tab
  • SQL Server browser started
  • Firewall set properly – you want to enable TCP and UDP traffic on port 1433
  • Server allows remote connections? In SSMS open properties for that instance and check Connections tab.
Share:
11,719
Robert
Author by

Robert

I don't consider work to actually be "work". As a .NET Developer, I love my job and it feels like I'm just hanging around with friends when I work. We work great as a team and produce a lot of valuable applications for our company. I love to play hockey and in my spare time and have a muscle car that I'm working on getting back on the road.

Updated on June 04, 2022

Comments

  • Robert
    Robert almost 2 years

    I have a WinForms program I am creating for a friend of mine that uses a SQL Server Express database. Locally, I can connect to my SQL Server Express fine and when I deploy the app to his computer, it works also. I'm having difficulty connecting to his SQL Server Express instance from my machine though (I'm trying to run the program in debug mode in vs2012 but connected to his database). The program uses Entity Framework in case that matters (I don't think it does).

    We've setup his firewall to allow my IP address to access his computer and his SQL Server... so I can log in via remote desktop and I can also connect using SSMS from my pc and see all the databases.... but why can't I connect using vs2012? I'm thinking it has something to do with the connection string but haven't found a working solution yet.

    Here's what I have tried:

    Got these from ConnectionStrings.com:

    Server=100.100.100.100\SQLExpress;Database=TestDB;User Id=UserID;Password=myPassword;
    
    DataSource=100.100.100.100\SQLExpress;Database=TestDB;User Id=UserID;Password=myPassword;
    

    Obviously the IP address has changed for the purposes of this post.

    Any ideas?

  • Robert
    Robert over 10 years
    Thanks Aaron...tunnel-vision is awful at times :)