Robert
Robert

Reputation: 1726

Connection string for SQL Server Express on remote computer?

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?

Upvotes: 2

Views: 12832

Answers (2)

Aaron Bertrand
Aaron Bertrand

Reputation: 280644

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

Upvotes: 1

Dwoolk
Dwoolk

Reputation: 1501

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.

Upvotes: 1

Related Questions