System.Data.SQLite.SQLiteException: 'SQL logic error no such table: Incident'
-
I'm trying to populate a combobox with a column in a SQLite database table. Im using an Absolute path in my connection string but Im getting an Error that the table doesn't exist. Ive read through other posts and still cant resolve the problem. Here is my code.
public Form1()
{
InitializeComponent();if (File.Exists(@"R:\\TEOP\\Tracker\\Tracker.db")) { SQLiteConnection conn; conn = new SQLiteConnection("Data Source=R:\\\\TEOP\\\\Tracker\\\\Tracker.db,version=3;"); conn.Open(); SQLiteCommand cmd; cmd = conn.CreateCommand(); cmd.CommandText = @"SELECT IncidentName FROM Incident;"; var dr = cmd.ExecuteReader(); while (dr.Read()) { IncidentCombo.Items.Add(dr\["IncidentName"\]); } }
}
Ive checked permissions and path. My query works in the database browser.
-
I'm trying to populate a combobox with a column in a SQLite database table. Im using an Absolute path in my connection string but Im getting an Error that the table doesn't exist. Ive read through other posts and still cant resolve the problem. Here is my code.
public Form1()
{
InitializeComponent();if (File.Exists(@"R:\\TEOP\\Tracker\\Tracker.db")) { SQLiteConnection conn; conn = new SQLiteConnection("Data Source=R:\\\\TEOP\\\\Tracker\\\\Tracker.db,version=3;"); conn.Open(); SQLiteCommand cmd; cmd = conn.CreateCommand(); cmd.CommandText = @"SELECT IncidentName FROM Incident;"; var dr = cmd.ExecuteReader(); while (dr.Read()) { IncidentCombo.Items.Add(dr\["IncidentName"\]); } }
}
Ive checked permissions and path. My query works in the database browser.
In problem posts like this, always copy'n'paste the exact error message. If the message indeed says your table doesn't exist, it has nothing to do with the connection string. It's telling you don't have a table called 'Incident' in your database. Check the spelling of the table name in your query and carefully compare to the table name in the database.
Asking questions is a skill CodeProject Forum Guidelines Google: C# How to debug code Seriously, go read these articles. Dave Kreskowiak
-
I'm trying to populate a combobox with a column in a SQLite database table. Im using an Absolute path in my connection string but Im getting an Error that the table doesn't exist. Ive read through other posts and still cant resolve the problem. Here is my code.
public Form1()
{
InitializeComponent();if (File.Exists(@"R:\\TEOP\\Tracker\\Tracker.db")) { SQLiteConnection conn; conn = new SQLiteConnection("Data Source=R:\\\\TEOP\\\\Tracker\\\\Tracker.db,version=3;"); conn.Open(); SQLiteCommand cmd; cmd = conn.CreateCommand(); cmd.CommandText = @"SELECT IncidentName FROM Incident;"; var dr = cmd.ExecuteReader(); while (dr.Read()) { IncidentCombo.Items.Add(dr\["IncidentName"\]); } }
}
Ive checked permissions and path. My query works in the database browser.
NOTE: DISCLAIMER: I have no experience with SQLite! This is just a shot in the dark from an ignorant non-expert: I tried to look up examples of SQL use, and saw them use a semicolon rather than a comma before 'version=3;' I also saw that opening a non-existing database will created one by the given name. So, if the entire string 'R:\\TEOP\\Tracker\\Tracker.db,version=3' is take as a database name, then you are opening a new, empty database, which obviously doesn't have an 'Incident' table. (I must admit that I am surprised if a database can be named R:\\TEOP\\Tracker\\Tracker.db,version=3, so this may be a completely wrong track to follow!)
-
NOTE: DISCLAIMER: I have no experience with SQLite! This is just a shot in the dark from an ignorant non-expert: I tried to look up examples of SQL use, and saw them use a semicolon rather than a comma before 'version=3;' I also saw that opening a non-existing database will created one by the given name. So, if the entire string 'R:\\TEOP\\Tracker\\Tracker.db,version=3' is take as a database name, then you are opening a new, empty database, which obviously doesn't have an 'Incident' table. (I must admit that I am surprised if a database can be named R:\\TEOP\\Tracker\\Tracker.db,version=3, so this may be a completely wrong track to follow!)
Thank you that was the problem ....A typing error replacing the "," with a ";" was the problem. Syntax is a killer at times!....lol
-
NOTE: DISCLAIMER: I have no experience with SQLite! This is just a shot in the dark from an ignorant non-expert: I tried to look up examples of SQL use, and saw them use a semicolon rather than a comma before 'version=3;' I also saw that opening a non-existing database will created one by the given name. So, if the entire string 'R:\\TEOP\\Tracker\\Tracker.db,version=3' is take as a database name, then you are opening a new, empty database, which obviously doesn't have an 'Incident' table. (I must admit that I am surprised if a database can be named R:\\TEOP\\Tracker\\Tracker.db,version=3, so this may be a completely wrong track to follow!)
Nice catch. I missed that one.
Asking questions is a skill CodeProject Forum Guidelines Google: C# How to debug code Seriously, go read these articles. Dave Kreskowiak