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

Ask A Question

Stats

  • Questions 86k
  • Answers 86k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Wouldn't the delayed execution and captured state of lambdas solve… May 11, 2026 at 5:18 pm
  • Editorial Team
    Editorial Team added an answer std::ends inserts a null character into the stream. Getting the… May 11, 2026 at 5:18 pm
  • Editorial Team
    Editorial Team added an answer I don't recommend it, the performance of serializing/deserializing a cookie… May 11, 2026 at 5:18 pm

Related Questions

When working with namespaces such as System.Data.Odbc or System.Data.OracleClient the various data reader methods
I am trying to add a column (MSSQL 2005) to a table (Employee) with
I am building a system for distributing packages (.zip archives) created by different organizations.
What is the correct way to get a control that was rendered by ASP.NET

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.