tags:

views:

30

answers:

1

Possible Duplicate:
app.config file in C# for MS SQL Server 2005 in VS 2008

I have C# .net project with SQL Server 2008 written in Visual Studio 2008. There I used the following connection string to connect with SQL Server:

string connectionString = @"server = HASIBPC\SQLEXPRESS; Integrated Security = SSPI; database = XPHotelManagementDatabase";

But problem is every time I take my application from one computer to another computer I need to change the "server" in "connectionString". I dont want to change this manually. I want this will change dynamically. How will I do that using app.config?

A: 

Put this in your app.config:

<configuration>
   <appSettings>
      <add key="server" value="HASIBPC\SQLEXPRESS" />
   <appSettings>
</configuration>

And then in your code, access it using:

return ConfigurationSettings.AppSettings["server"].ToString();
froadie
The OP asked the same question [here.](http://stackoverflow.com/questions/3533279/app-config-file-in-c-for-ms-sql-server-2005-in-vs-2008)
Robert Harvey
I'm sorry for this. My internet connection got disconnected when I submitted the question and I submitted this question again.