Change the Connecting string of the C# windows form application to it in another computer

I have a C# windows form application and I connect it to the SQL server in my computer. Now I going to deliver the software to a user. So, what can I do to change the connection string to the user SQL server? Is there any way to do the connection string computer independent? Kindly help me


  • SQL Server: Howto get foreign key reference from information_schema?
  • SQL 2 counts with different filter
  • How to automate executing stored procedure in SSIS with random parameters and output to a CSV file
  • Case statement not correctly matching expected values
  • Connecting php to MS SQL Server. Login failed
  • Drop all databases from server
  • How to us a Subquery to Update Multiple Column Values in SQL?
  • Is it possible to tell SSMS not to check if a column exists in a t-sql script?
  • SQL output parameters in C#
  • Insert entire DataTable into database at once instead of row by row?
  • How can I convert a varchar with hexadecimal value to int?
  • Persist a variable value in SSIS package
  • 4 Solutions collect form web for “Change the Connecting string of the C# windows form application to it in another computer”

    I’m assuming you’re hard-coding connection strings into your code. You need an application config file.

    Or you could use connection string like this (if database (SQL server) is on same machine as app using it and database name is the same) :

    Server=localhost\instanceName;Database=myDataBase;User Id=myUsername;Password=myPassword;

    instanceName could be “nothing” (default instance) or named instance (SQLEXPRESS).

    Or do it as @Xavier J suggested – store connection string in app config or INI file.

    application config files are one idea, but because they are managed through the IDE means have to change manually for deployment.
    Better to use the registry (cleaner too – no need to post-edit the file), and the installer can get conditional on where it’s deployed, alternatively ask the user during installation, skip if the registry entry already exists.), confirm the connection string at install time. database path/host/name exists…

    You can store it in the app.config of your project. Then if you wanted the user to give credentials you could make a form and save the string to the value of that configuration.

        <add key="connectionString" value="Connection string goes here"/>

    Then call it and set it using the ConfigurationManager

    ConfigurationManager.AppSettings["connectionString"] = "Your Value";

    Or you could just replace the connection string yourself in the file once its on the users computer

    MS SQL Server is a Microsoft SQL Database product, include sql server standard, sql server management studio, sql server express and so on.