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 don’t want to change this manually. I want this will change dynamically. How will I do that using app.config?
Here is a sample;
Note that
Data Source=.\SQLEXPRESS;attribute as your SQL Server and Server Instance name. Also, you do not need to restore your database from machine to machine if you use theAttachDbFilename=attribute.