SQL Server Express 2008 using (local) in the connection string

Is it possible to connect to the SQL Server Express 2008 database in ASP.NET with the server name (local), for example "server = (local)), integrated security = SSPI; database = DBNAME"?

I am working with another project developer, and it becomes annoying for me to have 2 different versions of web.config because it uses SQL Server 2008 and (local), but I cannot get it to work with SQL Server 2008 Express locally.

The database is located on the same computer as the .NET code, in case this is important.

Thanks.

+7
sql-server-express connection-string
source share
2 answers

You can use the SQL Server Configuration Manager tool to create an alias. Give an alias with the same name on your computer, and then you can simply refer to the alias in the configuration files.

I don't know if the Configuration Manager tool is really included in the Express version of SQL Server, but if not, you can just use the registry key (it still works with Express versions). Just ask your colleague to set up an alias and then export the following registry key:

HKEY_LOCAL_MACHINE \ SOFTWARE \ Microsoft \ MSSQLServer \ Client \ ConnectTo

Then you can import this key to your local computer. Something a little more complicated if you are on 64-bit Windows (because you need to set up an alias in both the 64-bit and 32-bit registry).

+1
source share

Assuming you both installed SQL Express with the default instance name " SQLEXPRESS ", you can have one connection string, for example:

server=.\SQLEXPRESS;integrated security=SSPI;database=DBNAME 

". in the connection string is used to represent the local machine.

+4
source share

All Articles