in

System.Data.SQLite

An open source ADO.NET provider for the SQLite database engine

No such table [failed SqliteCommand]

Last post 05-15-2008 12:45 PM by muddude. 2 replies.
Page 1 of 1 (3 items)
Sort Posts: Previous Next
  • 05-13-2008 9:57 PM

    No such table [failed SqliteCommand]

    I'm stumped - I can create a connection, open the database, get the dB schema - I know because 'connection.GetSchema()' works - but when I create a SqliteCommand, give it a normal SELECT command string and call cmd.ExecuteReader(), I get a "no such table" stop.

    The table does exist! Honest. I guess I could upload a screenshot, but I'm hoping you'll take my word for it. I even tried making another table with a different name, and trying again. No luck.  The database is not password protected. Here's the code 

                string cmdText = "SELECT * FROM t_People";

                SQLiteConnection c = new SQLiteConnection("Data Source = artbase.s3db");
                c.Open();
                SQLiteCommand cb = new SQLiteCommand(cmdText, c);
                DbDataReader rder = cb.ExecuteReader();
                return rder;

    Runtime error "no such table: t_People" 

    Filed under:
  • 05-14-2008 5:27 AM In reply to

    • Mark2
    • Top 10 Contributor
    • Joined on 04-24-2008
    • Posts 39

    Re: No such table [failed SqliteCommand]

    You do not include a pathname in your "Data Source"-statement, that means the program expects the database to be exactly in the same directory as the program. If this not the case SQLITE unfortunately and silently creates an empty database for you.

    The behaviour you describe will happen, e.g. when you tested your program successfully in the Debug subdirectory and then create the release version in the Release subdirectory.

    To be sure, try this one: "Data Source= artbase.s3db;FailIfMissing=True"

     

  • 05-15-2008 12:45 PM In reply to

    Re: No such table [failed SqliteCommand]

    Thanks - right on target. I looked 'bin\debug' and there it was, artbase.s3db, at 0k  (my grandma, what a small footprint you have). Have adjusted paths accordingly and everything seems to be working fine. And thanks for the quick response.

Page 1 of 1 (3 items)
Powered by Community Server (Commercial Edition), by Telligent Systems