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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T10:40:20+00:00 2026-06-01T10:40:20+00:00

I am trying to access an SQLite 3 database programmatically using the code below:

  • 0

I am trying to access an SQLite 3 database programmatically using the code below:

private void button1_Click(object sender, EventArgs e)
{
    try
    {

        string connectionPath = @"Data Source=C:\temp\sms.db";

        SQLiteConnection connection = new SQLiteConnection(connectionPath);

        SQLiteCommand command = connection.CreateCommand();
        connection.Open();
        string query = "SELECT * FROM Message";
        command.CommandText = query;
        command.ExecuteNonQuery();

        SQLiteDataAdapter dataAdaptor = new SQLiteDataAdapter(command);
        DataSet dataset = new DataSet();
        dataAdaptor.Fill(dataset, "messages");
        dataGridView1.DataSource = dataset.Tables["messages"];
        connection.Close();

    }

    catch
    {
        MessageBox.Show("error", "error", MessageBoxButtons.OK);
    }
}

However whenever I press the button this code is assigned to, it doesn’t catch on the Try Catch and display my message box, it freezes for a few seconds and debugs into the Program.cs file at the line shown below

    static void Main()
    {
        Application.EnableVisualStyles();
        Application.SetCompatibleTextRenderingDefault(false);
        Application.Run(new frmMainWindow()); **<----This Line**
    }
}

At that line it then displays this error to me

Could not load file or assembly ‘System.Data.SQLite, Version=1.0.76.0, Culture=neutral,
PublicKeyToken=db937bc2d44ff139’ or one of its dependencies.
An attempt was made to load a program with an incorrect format.

How can I overcome this error so I can query the database?

EDIT

My development OS is Win 7 x64 Prof
I have installed:
Setups for 64-bit Windows (.NET Framework 4.0)
Setups for 32-bit Windows (.NET Framework 4.0)
from heresystem.data.sqlite.org/index.html/doc/trunk/www/downloads.wiki

  • 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-01T10:40:21+00:00Added an answer on June 1, 2026 at 10:40 am

    Turned out Visual Studio was incorrectly referencing a different version of System.Data.SQLite.dll for some reason

    I removed the old reference, and copied the new System.Data.SQLite.dll files to the location:

    C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework.NETFramework\v4.0\Profile\Client

    Then added reference to it using Visual Studio again and it now works

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

Sidebar

Related Questions

I am trying to access member variables of a class without using object. please
What I'm trying to do is access an SQLite database, which is on a
I'm trying to use SQLite's C API to open a database and access some
This is the error I get while trying to access a sqlite database from
I am trying to store data in created SQLite database. Here is the code
I'm trying to test a simple SQLite database using Robolectric in my Android application.
Im trying to access a Sql CE 2005 database on a windows mobile device
I'm trying to access list data using SSRS 2008. I have created an XML
I'm trying to persist an Array of Arrays to my SQLite database in Rails.
I'm trying to select data from the database and I have the following code

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.