troubleshooting Question

System.Data.SQLite.SQLiteException: 'SQL logic error no such table: tags' - but the table does exist.

Avatar of Tom Knowlton
Tom KnowltonFlag for United States of America asked on
DatabasesC#Windows OSSQL
7 Comments1 Solution128 ViewsLast Modified:
Using nuget package Sqlite in a C# Windows Forms App in VS 2019 Community Edition.

I get this runtime exception:

SQL logic error
no such table

The table does exist, and the path is correct in the Data Source connection string.  I can open the self same table in Sqlite's DB Browser utility and it's there and the same select statement as the one in the code snippet below works fine:

  public static List<object> GetAllTags()
        {
            List<object> tempTagList = new List<object>();           

            m_dbConnection.Open();
            string sql = "select tagname from tags order by tagname asc";
            SQLiteCommand command = new SQLiteCommand(sql, m_dbConnection);
            SQLiteDataReader query = command.ExecuteReader();  ///////////////////////////////////////////// EXCEPTION GETS RAISED ON THIS LINE ////////////////////////////////////

            while (query.Read())
            {
                string temp = query.GetString(0);
                tempTagList.Add(temp);                
            }

            m_dbConnection.Close();

            return tempTagList;
        }



NOTE:  Here is the connection string to the database:

 public static class DataHelper
    {
        public static string DB_FILENAME = @"Data Source=C:\Users\ENDER\Desktop\DCT\DCT\bin\Debug\CBDB.db;";
        private static SQLiteConnection m_dbConnection = new SQLiteConnection(DB_FILENAME);

...


...

}




About SQL Lite
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 7 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 7 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros