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 7979837
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T09:53:08+00:00 2026-06-04T09:53:08+00:00

I have a project that uses an Access DB file for reference tables. This

  • 0

I have a project that uses an Access DB file for reference tables. This is to be used at work, but I am developing it at home. Up until now, I’ve simply run the debugger in VS2010, then copied the relevant class files, exe, etc from the /bin folder to a flash drive, and it’s worked fine. But with the DB added in, it suddenly crashes on launch.

I know the problem is the file location of the DB file. Originally the Build Action of the DB was sent to Content. I have changed it to Embedded Resource, which as far as I understand means it will be part of the exe file now.

Am I correct in this? If not, what option do I need to select to have the DB become just a compiled part of the exe, or one of the other dll’s?

  • 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-04T09:53:09+00:00Added an answer on June 4, 2026 at 9:53 am

    If the db file is embedded, you can’t access it to add/removes rows etc.
    Why did you change the build action to Embedded Resource ? It’ll be better to put as Content, so the db is a separate file than the exe (but still in the same directory), and then build the path to the db file (i.e. using Application.StartupPath).

    Anyway, if you want to set it as Embedded you’ll need to extract the db at runtime and store it somewhere before using it.

    Here is a method that can extract a file from the embedded resources (of course you’ll need to change the filename, or pass it as argument):

    private void ExtractFromAssembly()
    {
        string strPath = Application.LocalUserAppDataPath + "\\MyFile.db";
        if (File.Exists(strPath)) return; // already exist, don't overwrite
        Assembly assembly = Assembly.GetExecutingAssembly();
        //In the next line you should provide NameSpace.FileName.Extension that you have embedded
        var input = assembly.GetManifestResourceStream("MyFile.db");
        var output = File.Open(strPath, FileMode.CreateNew);
        CopyStream(input, output);
        input.Dispose();
        output.Dispose();
        System.Diagnostics.Process.Start(strPath);
    }
    
    private void CopyStream(Stream input, Stream output)
    {
        byte[] buffer = new byte[32768];
        while (true)
        {
            int read = input.Read(buffer, 0, buffer.Length);
            if (read <= 0)
                return;
            output.Write(buffer, 0, read);
        }
    }
    

    The file will be copied in the local application path, in the user directory. It’ll be done the first time the app is started, because otherwise the db file will be overwritten each time the application start (overwritten with the clean db package in the exe)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have got this project that uses excel for some calculation. This excel is
Hi i have an old project which uses an MS-Access file as DB. I
I have a C++ project that uses IBPP to access a firebird database. I
I have an old project that uses MPXJ library to access MS Project 2010.
I have project that uses Hibernate: hibernate-core-3.6.7.Final.jar In its POM I found: <dependency> <groupId>org.hibernate.javax.persistence</groupId>
I have a project that uses totoiseSVN. Before upgrading it to 1.7 version all
I have Midas project that uses a TDataSetProvider in one of RemoteDataModules in the
I have a project that uses two third party libraries, both of which make
We have a project that uses JPA/Hibernate on the server side, the mapped entity
I have a project that uses a System.Timers.Timer to update the position of motors.

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.