Enabling Remote SQL Express 2008 Network Connections on Vista

Published 17 September 08 07:30 PM

Today I spent way too long trying to enable remote network connections on my SQL 2008 Express database running on my Vista development machine so I thought I'd post the steps here. Please note that these settings may NOT be appropriate for your production environments. I'm a developer ;-), hence this is what I did to get the development environment working. If you need to set up production environments I'd read the SQL Server Books online.

Normally when developing code I always use the local SQL Express instance on my box and the default install takes care of everything so local connections via Visual Studio work fine. But what I was doing today was trying to connect a VPC to SQL 2008 Express on my host development machine in order to test some apps, simulating a network. When installing SQL 2005 or 2008 Express it locks out remote access to be on the safe side. Here's the basic steps you need to do to get it working:

1. Open up the SQL Server Configuration Manager. Programs / Microsoft SQL Server 2008 / Configuration Tools / SQL Server Configuration Manager.

2. Expand the SQL Server Network Configuration node and select the Protocols for SQLEXPRESS

3. Enable TCP/IP by right-clicking and selecting Enable, then OK.

4. Click on the SQL Server Services node and in the right panel right-click SQL Server (EXPRESS) and select restart to restart the service.

5. Right-click on the SQL Server Browser and select start to start the browser service if it isn't started already. This will allow you to access the SQL Express instance by the computer name.

6. Open up SQL Server Management Studio as Administrator. (If you don't have SSMS installed, get it here)

7. In the Object Explorer under the Security node, add a new user for the account that will be connecting by right-clicking and selecting "New User". This opens the Login Properties page. If you're on a domain then use Windows Authentication. For my VPC scenario it wasn't connected to a domain so I added a SQL Server login and password. (To enable SQL logins you need to first right-click on the SQL Express instance at the top, select Properties and under Security select "SQL Server and Windows Authentication mode".)

8. Select User Mapping on the Login Properties and check off the database you want to connect to. If you're just testing then you can select db_owner in the role membership to grant all access to the database, including altering the schema. Please note that this is not secure but it works for development and testing.

If you want to be secure you can go and specifically grant permissions under the Security node for the specific database back up in the Object Explorer. But if you're on a domain then I would recommend creating a least privileged Windows Security Group on your domain and adding that to a SQL Server Role that you can configure explicit permissions on (i.e. GRANT EXECUTE on your CRUD stored procs and GRANT SELECT on tables, don't let DELETE, INSERT and UPDATE directly). Then you can just use normal Windows security to add users on the domain to the group. This also lets you use integrated security in the connection strings which is much more secure.

9. Configure the Firewall. This is the step that I forgot and was banging my head on the wall 4-EV-R! Open up Windows Firewall and select Change Settings, select the Exceptions Tab and click Add Program. You'll need to select the SQLServer.exe in Program Files\Microsoft SQL Server\MSSQL10.SQLEXPRESS\MSSQL\Binn\ and the SQLBrowser.exe in Program Files\Microsoft SQL Server\90\Shared\. Then select Properties for each of them and select the "Change Scope" button. Then select the proper scope. For development and testing you could specify the remote computer's IP address or widen it to your network subnet. I recommend not allowing Internet users. ;-)

10. Configure the connection string. Now back in Visual Studio you can configure your connection string settings in your Project Settings (app.config). If you used Windows Authentication then it's really easy:

Data Source=SERVERNAME\sqlexpress;Initial Catalog=MyDatabase;Integrated Security=True

If you used a SQL Login then you need to supply a less secure connection string with the username and password:

Data Source=SERVERNAME\sqlexpress;Initial Catalog=MyDatabase;User ID=username;Password=password

I hope that works for you, it did for me. If you're still having trouble please see these troubleshooting tips in the library or ask a question on the SQL Server forums. I'm by no means an expert in SQL Server configuration or networks.

Enjoy!

Comment Notification

If you would like to receive an email when updates are made to this post, please register here

Subscribe to this post's comments using RSS

Comments

# a-foton » Enabling Remote SQL Express 2008 Network Connections on Vista said on September 17, 2008 10:39 PM:

PingBack from http://blog.a-foton.ru/2008/09/enabling-remote-sql-express-2008-network-connections-on-vista/

# Logan said on September 18, 2008 5:34 AM:

Hi Beth

Just wondering, you mention SQL Server Express 2005, saying that it locks out remote connections, will these steps work to enable remote connections when using SQL Server Express 2005?

Regards,

Logan

# Beth Massi said on September 25, 2008 12:19 PM:

Hi Logan,

Yep I think this is the same thing you need to do for SQL 2005 Express on Vista.

-B

# Logan said on September 29, 2008 4:24 AM:

Hi Beth,

You beauty thank you :) I keep getting these errors saying "default settings don't allow remote connections" or something... although, not so much now I've watched the windows forms over data video series and know how to do it right lol

Thanks again, and keep shelling out these awesome tips will ya.

Logan

# Andy Hinds said on October 10, 2008 9:52 AM:

I just want tosay thanks for writing this. I'm a novice and was searching all the wrong things until I found your post. So, thanks!

# Tim De Coen said on October 13, 2008 6:08 PM:

Thank you very much. This is just what i need. I've been trying a lot of things but they never worked.

TDC

# Mary Fran said on October 15, 2008 11:36 AM:

You're a life-saver!  I was banging my head against the wall and you've stopped the headache!!!!

# Muni Kumar said on November 20, 2008 6:35 AM:

Hi Beth,

I read you blog and several other hundred trying to figure out how to set up sql server on a small LAn(like a home network). You should use Mixed Mode Authentication. If you use windows Authentication(Integrated Security=True; in the connection string),unless you mirror each user on the network on the server computer, that user will not be able to login. A shortcut is to give the Guest account in every windows installation login rights to SQLSERVER. That is because  every network log on is presented in windows authentication mode as Guest to the SQLSERVER. The SQL books Online recommends using  WIndows Authentication mode as more secur. I cannot see how!

# Carl said on January 4, 2009 4:58 PM:

Does this work on Workgroups on a Local Network?

# Jure Žove said on January 4, 2009 6:11 PM:

Hello Beth,

I have an odd problem but i dont know if its the right topic :-) I have an VB application that connects to SQL Server Express 2008 on my computer. It works fine when i run it on my machine but when i run it on any other, it returns Network Instance 26 error. I enabled remote connections and if i type in the global IP (im behind a router) in the connection string (VB), it also works fine. If someone in local network tries to run the app, it crashes. I followed this manual but it didnt work :( (btw, i followed your How Do I videos when creating a database..)

# Jure Žove said on January 5, 2009 8:08 PM:

Fixed it -> the connection string on the DataSet was invalid :-) now it works perfectly! Again, your How Do I videos are great!

# Beth Massi said on January 7, 2009 1:20 PM:

Hi Carl,

It should. That's what I have here when I tested it.

Cheers,

-B

# j said on January 13, 2009 2:32 PM:

just another thank you from another fellow programmer who's on his way now thanks to this article

thanx!

# Willem said on February 3, 2009 10:17 AM:

Hi Beth. Great and helpful blog!

Can I add after having seen people experience difficulties: I will simply add on to your writing:

Beth:3. Enable TCP/IP by right-clicking and selecting Enable, then OK.

Willem: Double click the TCP/IP and click on the IP-adress tab. Go straight to "IPALL" - at bottom. Ensure Dynamic Ports contains a BLANK and add a port like 1433 to IP Port. If you have a named Instance leave the 1433 for some default and use 49172 (up to 65000)

Now you are ready to restart your instance's service again

"Beth:10. Configure the connection string. "

With the advent of the VS express editions, only WEB DEVELOPER can connect to a database engine as such. Use the following example to sort out your connection string.

<protocol>:<name\instance,<port>

e.g:

tcp:myMachine\MydbInstance,49172 - this if you want to use TCP/IP.

Hope this will complete Beth's very welcome blog a little.

# Ferdinand said on February 27, 2009 4:28 AM:

Thanks, this saved me a lot of time!

# Jeremy said on March 17, 2009 10:59 PM:

Great article. I got it working in about 2 minutes. Thanks.

# Dan said on March 20, 2009 12:20 PM:

I found this article MOST helpful!  You're a peach!

# delta dirac said on April 4, 2009 9:27 AM:

do you beleive what you're telling? ("it works for me")

no it doesn't work for no body there are much more to do please tell people completely or don'tell anything.people are spending days and days oh it works for her so am i an ideot???

# Beth Massi said on April 4, 2009 11:11 AM:

Hi Delta Dirac,

Well it seems to have worked for many people here acoording to the other comments. It's kind of hard to help you if you don't explain what steps you tried or what error you are getting.

-B

# Delta Dirac said on April 4, 2009 4:17 PM:

ofcourse i know you don't have to solve any personel difficulties met when programming,at least you don't have time for that Just wanna say,this sql networking thing is not so simple,i passed many many obstacles,first 'the remote connection settings and allowing named pipes and tcp/ip ' then 'user guest doesn't allowed in something',than i made logins on server,i made everything and everything,i gace roles i gave permissions but no way at the and of the fourth day i 've got a "User does not have permission to perform this action" what permisson i gave all te roles all the permissions, you know what something wrong with me or with these procedures,anyway thanks for your interest to my rude and angry comment(but i am still angry this is tha fact :))

# jose said on April 21, 2009 12:20 AM:

When they say "Firewall" ... it's not just windows firewall, but ANTIVIRUS FIREWALL too!!!!

That was the key for me...  may be a little kork-head  (cabeza'e termo para latinos), don´t care. That was it. 11:30 pm, at client site... Ramon, you saved my day!!!

# Matt said on June 26, 2009 10:06 AM:

Awesome tip!  Love the detail and step by step approach.  Worked like a charm!

# Gary said on July 7, 2009 10:18 AM:

Thanks for the straightforward post and step by step instructions.

# Kevin said on July 16, 2009 10:42 PM:

THANK YOU!

I had been wrestling with this for two Evenings!!

(Even though the Error Message was Very Descriptive and Telling me what was wrong!!)

Thanks Again!

# Itsu said on July 22, 2009 10:00 PM:

Very helpful post.

Willem,

your pointing out the need to disable the dynamic port was a life saver.

Thanks.

# cj said on July 31, 2009 1:31 PM:

Beth (and Willem!)...

Thanks a lot for all this info!  It really helped us.

# Klaus Lozie said on September 5, 2009 10:16 AM:

Thank you for your explanation.

Again a step further.

Best regards

# Rob said on September 22, 2009 2:51 AM:

Thanks Beth!

You've helped get my project another step forward (again!)

# Kadilac said on September 22, 2009 9:30 AM:

v been listen to ur CBTs neva knw u r that pretty ,  well thanks for the post that has really helped me alot.

# Raphael said on November 4, 2009 2:28 AM:

Hii,

I was wondering if there's a good tutorial for connecting a Visual basic 2008 database app to the SQL 2008 database trough the network and what do do for it.. cause i made a dbase in SQL server Managment Studio, via tutorial, but i dont know for far how to connect it..

I'm creating a app on the laptop, en the sql server 2008 & managment  database are on my local pc.

THnx in advanced!

Btw.. Your tutorials are very good.

# Beth Massi said on November 4, 2009 1:15 PM:

Hi Raphael,

Take a look here:

http://msdn.microsoft.com/en-us/library/ms171886.aspx

You can connect to a remote database in Visual Studio and it will save that in the app.config file so that if you need to change the database location you don't have to recompile your application.

HTH,

-B

# Fred Zarguna said on November 10, 2009 12:24 AM:

On x64 bit systems, the SQL Browser.exe will be in "c:\Program Files (x86)\Microsoft SQL Server\90\Shared\sqlbrowser.exe"

SQLServer.exe will still be in the same place as above

Leave a Comment

(required) 
(optional)
(required) 

  
Enter Code Here: Required

About Beth Massi

Beth is a Program Manager on the Visual Studio Community Team at Microsoft and is responsible for producing and managing content for business application developers, driving community features and team participation onto MSDN Developer Centers (http://msdn.com), and helping make Visual Studio one of the best developer tools in the world. She also produces regular content on her blog (http://blogs.msdn.com/bethmassi), Channel 9, and a variety of other developer sites and magazines. As a community champion and a long-time member of the Microsoft developer community she also helps with the San Francisco East Bay .NET user group and is a frequent speaker at various software development events. Before Microsoft, she was a Senior Architect at a health care software product company and a Microsoft Solutions Architect MVP. Over the last decade she has worked on distributed applications and frameworks, web and Windows-based applications using Microsoft development tools in a variety of businesses. She loves teaching, hiking, mountain biking, and driving really fast.

This Blog

Syndication

Page view tracker