Gotcha on setting up a data connection

This one gets me every time. When you set up a new data connection to a database running on a local copy of Sql Server Express, in the “Add Connection” dialog you need to prefix your machine name to the defaulted value of “SQLEXPRESS”. E.g. if the network name of your PC is called “devpc”, then the connection string is:

  • DEVPC\SQLEXPRESS

While this is the obvious choice and works for many circumstances, a subtle variation is to use the following instead:

  • localhost\SQLEXPRESS

This now points the connection to an instance of SQL Server Express running on your local machine. If working in a team where each developer needs their own local copy of a database, then setting this in the web.config file can be a real help.

Leave a Reply