Click here to Skip to main content
15,881,588 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi.
Can someone please help me to understand the meaning of this peculiar sqlite error and what's the cause of it ?
it's in C#
and here's my C# code.
C#
try
            {
                string query = @"insert into tbl (pkey, field)
                            values (@_pkey, @_txt);";

                string conString = @"Data Source = \testdb.s3db; version = 3;";
                SQLiteConnection con = new SQLiteConnection(conString);
                con.Open();
                SQLiteCommand cmd = new SQLiteCommand(query, con);
                cmd.Parameters.Add("@_pkey", System.Data.DbType.Int32).Value = 10;
                cmd.Parameters.AddWithValue("@_txt", "hello world");
                cmd.ExecuteNonQuery();
            }
            catch (Exception ex)
            { Console.WriteLine(ex.Message); }


But when I click the run, it displays this in the cmd.

SQL logic error or missing database
no such table: tbl
Press any key to continue . . .


And Im dead sure that there's a database and a table which fits the queries.
I tried changing the table name.

What's the wrong with this ?

Thanks in advance.
Posted
Comments
DamithSL 12-Feb-15 8:17am    
what is the path of your sqlite database?

1 solution

Your connection string is probably at fault ... try
C#
string conString = @"Data Source = c:\myFolder\testdb.s3db; version=3;";
replacing c:\myFolder with the actual path to the database
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900