-1

I was wondering what would happen to a program's connection to the database after compiling it to setup.exe? Will the data from the server explorer be saved somewhere after producing a setup installer so it could dynamically be changed later?

I'm still a bit new in coding. Just barely started. So I'm not really sure if my questions would make any sense to all the experts. I hope someone could enlighten me. Thank you.

  • 2
    It all depends how you've provided your connection string in the first place. We need a bit more detail. – Dale K Jul 15 '21 at 05:23
  • Typically, installers will just make sure all the files are places at the correct place, and possibly run some configurations etc. Things like connections strings will typically be stored in some configuration file, and there is not really anything special about such files from the installers point of view, unless you add some custom steps to the installer. – JonasH Jul 15 '21 at 07:45

1 Answers1

0

It all depends on what form of Database and what settings you had in your project.

case 1:

you are using a server-client Database. Server-client databases are like Sql-Server, MySql, Postgresql, Oracle..... Usually they have a host, username, password and/or authentication method. In this case, and while you are configuring your database with in your project in visual studio, you can choose to save the connection string with in your configuration file resources or hard code it in the application.

The Data will stay on the database server.

Case 2:

You are using one of file Database solutions like Sqlite, VistaDB, Acess DB file, XML based DB files, Sql-Compact SQL-CE (obsolete and replaced with SqlExpress)...etc.

In this case, the DB file (which should be in your project file and you have chosen from visual studio the option of (copy if newer)) will be included with your project with the data in it. You have to be sure in this case the proper assemblies are present with you your application *.dll. Your installer have nothing much to do here unless the DB solution you have chosen said other wise.

For example, if you used SqlExpress your installer should be sure that it is present when your user installs your application and if not it either installs it or instruct the user (at least by providing proper links) the methods to install it.

As for the connection string it takes the same conditions of case 1.

Hence you tagged your question with #sql-server I will assume you are looking for the SqlExpress case. If that's the case I will refer you to the couple of links which will provide you with further details:

1- How do I connect to an MDF database file?

2-How do I connect to an .mdf (Microsoft SQL Server Database File) in a simple web project?

3-C# - Connect to MDF database

4-THE ‘CONNECTION STRING’ STRING OF CONNECTION WITH DATABASE. AN EXAMPLE OF USING IN APPLICATIONS

Finally remember web search is always your friend:

5-c# sql server connection string attach database file (in google search)

Mohammed Mahmoud
  • 59
  • 1
  • 3
  • 10