Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8424131
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T03:54:22+00:00 2026-06-10T03:54:22+00:00

I am doing a SETUP project for a C# winforms, sqlite application. Connection string

  • 0

I am doing a SETUP project for a C# winforms, sqlite application.
Connection string seems to a bit of a problem. The user will put the Database he wants to work with at a location(which v will tell him). In this example it is "C:\\Program Files(x86)\\DefaultCompany\\RSetup"; The user can work his own copy of the DB.

So I am setting the data directory to this path in the Program.cs Main
This is the only way I can think of. If there is a better way thats grt!!.

 App.config 

        <add name="ConnString" connectionString="|DataDirectory|\MySQlite.db;Compress=True;Version=3"
              providerName="System.Data.Sqlite" />

  Program.cs 
    Setting the datadirectory to the path of the executable. Currently hard coded the path of the executable 
      static void Main()
            {

                   AppDomain.CurrentDomain.SetData("DataDirectory","C:\\Program Files(x86)\\DefaultCompany\\RSetup");

This doesn’t seem to be working. It doesn’t give any error except the data is not blank. Doesn’t seem to be working in both set up and the regular project

Thank you
JC

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T03:54:23+00:00Added an answer on June 10, 2026 at 3:54 am

    You could ask the user where the database is located, store that path somewhere (such as User Settings) and then you can retrieve it at any time. This would give the user more flexibility of where to put it and multiple users on the same machine could have their own database if desired.

    Here is some pseudocode…

    string dbLocation = Properties.Settings.Default.DatabaseLocation;
    if (string.IsNullOrWhiteSpace(dbLocation)
    {
        dbLocation = AskUserForLocation();
        Properties.Settings.Default.DatabaseLocation = dbLocation;
        Properties.Settings.Default.Save();
    }
    
    AppDomain.CurrentDomain.SetData("DataDirectory",dbLocation);
    

    Using this approach you could also add a menu option to allow the user to change the location if desired.

    It also gives you the ability to retrieve the value anywhere, including where you create a connection, you can append the path to the location between where you read the connection string and you create a new connection.

    SQLiteConnection myConnection = new SQLiteConnection;();
    myConnection.ConnectionString = Path.Combine(Properties.Settings.Default.DatabaseLocation, myConnectionString);
    myConnection.Open();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

So, I'm doing a setup project, all written in VB.NET, and I need to
while doing the build of my dontnet 4.0 project setup i'm getting following errors
I am trying to build a setup file which will install my vb.net application
I'm doing a windows service setup project on VS2008, it has a custom action
I have a VS2008 setup project, which creates a setup.msi which installs a WinForms
For my Rails project, I use custom code to setup my database before each
I'm doing an iOS project using ARC and storyboard. Currently the setup is as
I am doing a Windows forms application.I am using MS Access as database.I need
I setup a jsFiddle to show what I'm doing: http://jsfiddle.net/UfzCS/ Basically the border I
Doing my first SL4 MVVM RIA based application and i ran into the following

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.