Skip to content
Advertisement

SQLite C# System.Data.SQLite.SQLiteException

I want to insert data into a database via sqlite but each time I got the error below:

Connection Established Successfully…

code = Error (1), message = System.Data.SQLite.SQLiteException (0x800007BF): SQL logic error near “hpi_caseid”: syntax error at System.Data.SQLite.SQLite3.Prepare(SQLiteConnection cnn, String strSql, SQLiteStatement previous, UInt32 timeoutMS, String& strRemain) at System.Data.SQLite.SQLiteCommand.BuildNextCommand() at System.Data.SQLite.SQLiteCommand.GetStatement(Int32 index) at System.Data.SQLite.SQLiteDataReader.NextResult() at System.Data.SQLite.SQLiteDataReader..ctor(SQLiteCommand cmd, CommandBehavior behave) at System.Data.SQLite.SQLiteCommand.ExecuteReader(CommandBehavior behavior) at System.Data.SQLite.SQLiteCommand.ExecuteNonQuery(CommandBehavior behavior) at System.Data.SQLite.SQLiteCommand.ExecuteNonQuery()
at Dapper.SqlMapper.ExecuteCommand(IDbConnection cnn, CommandDefinition& command, Action 2 paramReader) at Dapper.SqlMapper.ExecuteImpl(IDbConnection cnn, CommandDefinition& command) at Dapper.SqlMapper.Execute(IDbConnection cnn, String sql, Object param, IDbTransaction transaction, Nullable`1 commandTimeout, Nullable 1 commandType) at ConsoleApplication1.SqliteDataAccess.SaveCase(CaseModel CasesData) in C:UsersmansourmDocumentsVisual Studio 2015ProjectsConsoleApplication1ConsoleApplication1SqliteDataAccess.cs:line 29 at ConsoleApplication1.Program.test() in C:UsersmansourmDocumentsVisual Studio 2015ProjectsConsoleApplication1ConsoleApplication1Program.cs:line 249

//App.config

Data Base screenshot

I have tried with a relative path also but I got the same error.

Thank you in advance!

Advertisement

Answer

It seems you have missed the parenthesis after your table’s name and after the Values keyword, i.e around hpi_caseid and @hpi_caseid:

Also you have declared the parameter but didn’t specify it’s value, you need to specify a value something like this

User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement