Link to home
Start Free TrialLog in
Avatar of Umesh Modi
Umesh Modi

asked on

create setup file (EXE) for c# windows application with using database of SQLite.

I want to create setup file (EXE) for c# windows application with using database of SQLite.
Avatar of Chinmay Patel
Chinmay Patel
Flag of India image

Hi Umesh,

Create and Deploy are two different things. Which one you want to do? Also how comfortable you are with C# in general?

You already have asked a question similar to this : https://www.experts-exchange.com/questions/29123475/create-deploy-exe-file-of-windows-application-in-c-with-database-of-mysql.html.

In that question it is MySQL, here it is SQLite. There are many experts here who would want to help you, but you have to clarify your question in order to get better answers.

Regards,
Chinmay.
Hi Umesh,

It's me again. I am going to use most of the stuff from my previous answer. I hope you won't mind it.

In your question you have asked 3 distinct things
1. Create an app (WPF/WinForm/Console)
2. Connect it with a MySQL Database
3. Deploy this app (and though you have not mentioned it out loud, I will assume that this deployment has to be along with the database OR maybe using a central server)

Now I will try to answer all three of them one by one.
1. Creating the app
 I was planning to write an article about this but then I thought why should I re-invent the wheel? So here, from my most beloved tech documentation site(of late), It can't get any better than this - article - https://docs.microsoft.com/en-us/visualstudio/ide/step-1-create-a-windows-forms-application-project?view=vs-2017

2. Connect with a SQLite Database
From above step 1, I am hoping you have created an app, let's call it MyApp. Now, this MyApp's project is open in Visual Studio. Assuming this, I will move forward. I am also assuming you have installed and created a SQLite database and it is accessible to you.
1. Click Tools, then click NuGet Package Manager, and then click Package Manager Console:
2. The Package Manager Console will appear in the bottom section of Visual Studio. Type "Install-Package Install-Package System.Data.SQLite" and press Enter:
3. Now, you can follow this article to understand how to connect to SQLite
https://www.thoughtco.com/use-sqlite-from-a-c-application-958255

Refer to: https://www.connectionstrings.com/sqlite/ to see various formats of connection string.

3. Deploy the app
Now, we have 2 scenarios. A. With the database B Without the database. While I will not recommend SQLite for a multi-user environment, it can work in that fashion so the scenarios do not change from my last answer.
A. With Database
You will copy the database to appropriate folder in your app's root directory and include it in your project using Visual Studio. In any of the installer, you will select that folder for deployment and we are good to go (Not so much but there are so many things to consider here, I don't think that this question is appropriate to handle all those factors - once you have made some progress I am sure we can fine tune the deployment part)
B. Without the Database
In case you have a centrally accessible database, all you need to do is instead of hard-coding the SQLite Connection string in your cod, you will configure it in your app.config and use it from there. And you won't have to deploy the database along with your app installer. Personally, I will always use connection string from the app.config in both A & B Scenarios, it just makes it that much easier for me to manage my deployments.
<configuration>  
    <connectionStrings>  
      <clear />  
      <add name="Name"   
       providerName="System.Data.ProviderName"   
       connectionString="Valid Connection String;" />  
    </connectionStrings>  
  </configuration>  

Open in new window

You can read more about this technique from here: https://docs.microsoft.com/en-us/dotnet/framework/data/adonet/connection-strings-and-configuration-files

Phew... this one is a long one too. But that god i could copy most of the stuff from my last response. :P

Regards,
Chinmay.
This question needs an answer!
Become an EE member today
7 DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform.
View membership options
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.