Deploying a database and application using ClickOnce

I am new to ClickOnce. I created a WinForms application using C # and SQL Server Express. My database is currently located in the mssql data folder. The connection string is in the app.config file.

<add name="default" providerName="System.Data.SqlClient" connectionString="Server=localhost\SQLEXPRESS;Database=DBase;Trusted_Connection=True;" /> 
  • How do I add a database file to deploy it with the application?

  • In which folder will the database be deployed and will my connection string (above) work?

+4
source share
1 answer

You have several options. First, if it is a simple database, I recommend that you stop using SQL Express and use SQL Server Compact. A compact SQL database is a file that can be associated with the installation of your application. Below is a link leading you through the process of creating an SQL Compact database.

http://technet.microsoft.com/en-us/library/ms173009.aspx

The following link discusses how to configure the necessary dependencies and prerequisites for SQL Server Compact. (Note: you will need to scroll to the Private File-Based Deployment section.)

http://msdn.microsoft.com/en-us/library/aa983326(v=VS.100).aspx

If you have a complex database or it can exceed the 3 GB limit set for SQL Compact databases, the only alternative is to install SQL Server Express as a prerequisite for your application, and after installing it, create in your application that checks if your database in SQL Express and, if not, starts the procedure for creating and updating the database.

In my case, I have a heavy data application that was written before SQL Compact was released and should have worked in environments that were often disconnected from our servers. I had to use SQL Express so that we had to develop a mechanism for checking database updates when the server was available. If there are updates, the encrypted script files are downloaded and executed sequentially with respect to the child database. After updating the database container, the procedure for checking and synchronizing data is called.

- EDIT -

I would like to quickly answer this, yes, you can link and attach the SQL Server database to a local instance of SQL Server. There are many obstacles to this, and if you have a user base that uses several versions of Windows, PC architecture, and several different security scenarios, you will probably have a problem with sequentially connecting the database to the user's SQL Server. Yes, it can be done. However, I would recommend avoiding this scenario at all possible costs.

+6
source

All Articles