Sunday, February 19, 2012

Connection String for SQL 2005 Express

Hi,
My C# app uses SQL Server 2005 Express edition.
I store my connection string in a config file.
My application will run on numerous machines and therefore the machine name
will be different each time. What I would like is a generic connection strin
g
so that I don't have to change it each time I install my app on a different
machine.
I therefore want to avoid specifing the machine name in the connection
string as shown below :-
"Data Source=MachineName;Initial Catalog=pubs;Integrated Security=SSPI;"
Is there any way to make this connection string generic so that it can stay
the same between different machines?
Thanks
MaccaIf you run your application on the same machine as the database, . (period)
works as a server name. So if your install SQL Express with the default
instance name, the server name is .\SQLEXPRESS
--
This posting is provided "AS IS" with no warranties, and confers no rights.
Use of included script samples are subject to the terms specified at
http://www.microsoft.com/info/cpyright.htm
"Macca" <Macca@.discussions.microsoft.com> wrote in message
news:B0A6D9FF-6715-4BBD-83BB-0C8B1F9A7098@.microsoft.com...
> Hi,
> My C# app uses SQL Server 2005 Express edition.
> I store my connection string in a config file.
> My application will run on numerous machines and therefore the machine
> name
> will be different each time. What I would like is a generic connection
> string
> so that I don't have to change it each time I install my app on a
> different
> machine.
> I therefore want to avoid specifing the machine name in the connection
> string as shown below :-
> "Data Source=MachineName;Initial Catalog=pubs;Integrated Security=SSPI;"
> Is there any way to make this connection string generic so that it can
> stay
> the same between different machines?
> Thanks
> Macca

No comments:

Post a Comment