sqlQuery = "INSERT INTO community_market" +
"VALUES (" + a.transaction_id + ",'" + a.community_name + "'," +
a.community_id + ",'" + a.item_name + "'," +
a.item_quantity + "," + a.price + ");";
这是我正在尝试运行的查询,我得到的错误是:
SqliteSyntaxException:near" 1":语法错误 Mono.Data.SqliteClient.SqliteCommand.GetNextStatement(IntPtr pzStart,System.IntPtr& pzTail,System.IntPtr& pStmt) Mono.Data.SqliteClient.SqliteCommand.ExecuteReader(CommandBehavior behavior,Boolean want_results,System.Int32& rows_affected) Mono.Data.SqliteClient.SqliteCommand.ExecuteReader(CommandBehavior行为) Mono.Data.SqliteClient.SqliteCommand.ExecuteDbDataReader(CommandBehavior行为) System.Data.Common.DbCommand.ExecuteReader() System.Data.Common.DbCommand.System.Data.IDbCommand.ExecuteReader()
可以使用一些帮助
答案 0 :(得分:5)
我想你忘记了community_market
和VALUES
之间的空格:
sqlQuery = "INSERT INTO community_market " +
"VALUES("+a.transaction_id+",'"+ a.community_name+"',"+
a.community_id+",'"+ a.item_name+"',"+ a.item_quantity+","+a.price+");";
此外,SQL Injection可能会引起一些兴趣。