Home All Groups Group Topic Archive Search About

Connection String Question

Author
17 Jan 2006 3:21 PM
Andrew
Hello, friends,

We have a connection string in our .net app configuration file like the
follows:

"packet size=4096;data source=server349;persist security info=False;initial
catalog=universalDB;user=everyone;password=everyone;"

Since each server has its own database instance, each time we deploy app to
a new server, we have to modify connection string: changing data source name,
say, from server349 to server712

Can we have a connection string that we don't have to modify connection
string each time deploying to a new server? What is syntax?

Thank you for your help.

Author
17 Jan 2006 3:39 PM
Sahil Malik [MVP C#]
Well, the answer is two fold

a) Yes - you can change the connection string to say (local) instead of
(server349), or any other such trick.
b) The connex. string should be in the config file anyway, so changing it
shouldn't be a big deal.


- Sahil Malik [MVP]
ADO.NET 2.0 book -
http://codebetter.com/blogs/sahil.malik/archive/2005/05/13/63199.aspx
----------------------------------------------------------------------------


Show quote
"Andrew" <And***@discussions.microsoft.com> wrote in message
news:8733137B-92A3-43EB-85D4-1F58468553B9@microsoft.com...
> Hello, friends,
>
> We have a connection string in our .net app configuration file like the
> follows:
>
> "packet size=4096;data source=server349;persist security
> info=False;initial
> catalog=universalDB;user=everyone;password=everyone;"
>
> Since each server has its own database instance, each time we deploy app
> to
> a new server, we have to modify connection string: changing data source
> name,
> say, from server349 to server712
>
> Can we have a connection string that we don't have to modify connection
> string each time deploying to a new server? What is syntax?
>
> Thank you for your help.
Author
17 Jan 2006 3:58 PM
Andrew
Thank you. I will change data source=server349 to data source=local

The reason why this is important to us is because sometimes people forgot to
change this parameter, and caused big problem since all data were updated in
the WRONG server.

Show quote
"Sahil Malik [MVP C#]" wrote:

> Well, the answer is two fold
>
> a) Yes - you can change the connection string to say (local) instead of
> (server349), or any other such trick.
> b) The connex. string should be in the config file anyway, so changing it
> shouldn't be a big deal.
>
>
> - Sahil Malik [MVP]
> ADO.NET 2.0 book -
> http://codebetter.com/blogs/sahil.malik/archive/2005/05/13/63199.aspx
> ----------------------------------------------------------------------------
>
>
> "Andrew" <And***@discussions.microsoft.com> wrote in message
> news:8733137B-92A3-43EB-85D4-1F58468553B9@microsoft.com...
> > Hello, friends,
> >
> > We have a connection string in our .net app configuration file like the
> > follows:
> >
> > "packet size=4096;data source=server349;persist security
> > info=False;initial
> > catalog=universalDB;user=everyone;password=everyone;"
> >
> > Since each server has its own database instance, each time we deploy app
> > to
> > a new server, we have to modify connection string: changing data source
> > name,
> > say, from server349 to server712
> >
> > Can we have a connection string that we don't have to modify connection
> > string each time deploying to a new server? What is syntax?
> >
> > Thank you for your help.
>
>
>
Author
17 Jan 2006 4:08 PM
Andrew
change it to local did not work???

Show quote
"Sahil Malik [MVP C#]" wrote:

> Well, the answer is two fold
>
> a) Yes - you can change the connection string to say (local) instead of
> (server349), or any other such trick.
> b) The connex. string should be in the config file anyway, so changing it
> shouldn't be a big deal.
>
>
> - Sahil Malik [MVP]
> ADO.NET 2.0 book -
> http://codebetter.com/blogs/sahil.malik/archive/2005/05/13/63199.aspx
> ----------------------------------------------------------------------------
>
>
> "Andrew" <And***@discussions.microsoft.com> wrote in message
> news:8733137B-92A3-43EB-85D4-1F58468553B9@microsoft.com...
> > Hello, friends,
> >
> > We have a connection string in our .net app configuration file like the
> > follows:
> >
> > "packet size=4096;data source=server349;persist security
> > info=False;initial
> > catalog=universalDB;user=everyone;password=everyone;"
> >
> > Since each server has its own database instance, each time we deploy app
> > to
> > a new server, we have to modify connection string: changing data source
> > name,
> > say, from server349 to server712
> >
> > Can we have a connection string that we don't have to modify connection
> > string each time deploying to a new server? What is syntax?
> >
> > Thank you for your help.
>
>
>
Author
17 Jan 2006 5:33 PM
Sahil Malik [MVP C#]
not "local" .. try "(local)" <-- note the parenthesis

or "." or "127.0.0.1" .. anything like that.

- Sahil Malik [MVP]
ADO.NET 2.0 book -
http://codebetter.com/blogs/sahil.malik/archive/2005/05/13/63199.aspx
----------------------------------------------------------------------------
Show quote
"Andrew" <And***@discussions.microsoft.com> wrote in message
news:2E355238-7AEC-4B30-8E15-C4D76A077EF2@microsoft.com...
> change it to local did not work???
>
> "Sahil Malik [MVP C#]" wrote:
>
>> Well, the answer is two fold
>>
>> a) Yes - you can change the connection string to say (local) instead of
>> (server349), or any other such trick.
>> b) The connex. string should be in the config file anyway, so changing it
>> shouldn't be a big deal.
>>
>>
>> - Sahil Malik [MVP]
>> ADO.NET 2.0 book -
>> http://codebetter.com/blogs/sahil.malik/archive/2005/05/13/63199.aspx
>> ----------------------------------------------------------------------------
>>
>>
>> "Andrew" <And***@discussions.microsoft.com> wrote in message
>> news:8733137B-92A3-43EB-85D4-1F58468553B9@microsoft.com...
>> > Hello, friends,
>> >
>> > We have a connection string in our .net app configuration file like the
>> > follows:
>> >
>> > "packet size=4096;data source=server349;persist security
>> > info=False;initial
>> > catalog=universalDB;user=everyone;password=everyone;"
>> >
>> > Since each server has its own database instance, each time we deploy
>> > app
>> > to
>> > a new server, we have to modify connection string: changing data source
>> > name,
>> > say, from server349 to server712
>> >
>> > Can we have a connection string that we don't have to modify connection
>> > string each time deploying to a new server? What is syntax?
>> >
>> > Thank you for your help.
>>
>>
>>

AddThis Social Bookmark Button