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

  • Home
  • SEARCH
  • 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 105943
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T01:31:08+00:00 2026-05-11T01:31:08+00:00

What is the correct way to work with SQLite in WPF and ASP.NET MVC?

  • 0

What is the correct way to work with SQLite in WPF and ASP.NET MVC?

  • In WPF, I have a test.sqlite file into a directory called App_Data but when I compile and run it, it doesn’t copy the database into ../bin/Debug so of course it can’t find it. But if I manually copy the test.sqlite file into ../bin/Debug, then it works. But this can’t be how one would develop an application which has a local database that it reads and writes to, right? How can I mark the database as ‘part of the application’ so when it is compiled and run, it gets copied and can be used? Or is this part of the development/publish process? What am I missing here, I think I have a web metaphor here that just doesn’t work with the Windows application way of doing things.

  • In ASP.MVC, I have copied the same code that accesses the database in WPF, but it keeps saying it ‘can’t open the database’ on the connection.Open() line. I have ‘../App_Data/test.sqlite’ which I understand is the right place to put it to access files. However, I tried to write a text file to ‘../App_data’ and got a UnauthorizedAccessException’ so I assume the problem is that I don’t have right to read/write here. How can I change that?

        private string getData() {     StringBuilder sb = new StringBuilder();     //string fullPathAndFileName = Server.MapPath('App_Data/testnew.sqlite');     using (SQLiteConnection conn =            new SQLiteConnection(@'Data Source=' + Server.MapPath('App_Data/testnew.sqlite')))     {         StringBuilder query = new StringBuilder();         query.Append('SELECT * ');         query.Append('FROM members ');         query.Append('ORDER BY firstName');         using (SQLiteCommand cmd = new SQLiteCommand(query.ToString(), conn))         {             conn.Open();             using (SQLiteDataReader dr = cmd.ExecuteReader())             {                 while (dr.Read())                 {                     //Console.WriteLine(dr.GetValue(0) + ' ' + dr.GetValue(1));                       string id = dr.GetValue(0).ToString();                     string firstName = dr.GetValue(1).ToString();                     sb.Append(firstName + ', ');                  }             }         }     }     return sb.ToString();  } 
  • 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. 2026-05-11T01:31:08+00:00Added an answer on May 11, 2026 at 1:31 am

    You can add the test.sqlite file to your WPF project and in the properties window specify the ‘Copy To Output Directory’ : ‘Copy always’. This way every time you compile your project, the file will be automatically copied to the output directory.

    Concerning your UnauthorizedAccessException have you tried granting read and write permissions on the App_Data folder for the ASP.Net Service account? To find out the account used to run the application pool you can write a simple test.aspx page:

    <%@ Page Language='C#' %> <script runat='server'>   protected override void OnLoad(EventArgs e)   {       Response.Write(System.Security.Principal.WindowsIdentity.GetCurrent().Name);       base.OnLoad(e);   } </script> 
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

What is the correct way to convert ASP.NET SOAP-based web services to JSON-based responses?
What is the correct way to import a C++ class from a DLL? We're
What is the correct way to do this? For example, how would I change
What is the correct way to check if a value is a date/number in
Is there a correct way in Windows Forms to flash a titlebar without having
What is the 'correct' way to store a native pointer inside a Java object?
What is the correct way of retrieving maximum values of all columns in a
What is the correct way of iterating over a vector in C++? Consider these
What is the correct way to separate between F1 and i.e. CTRL + F1
I have a problem in JDBC driver for SQLite. I am executing a query

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.