-1
sqlQuery = "INSERT INTO community_market" +
           "VALUES (" + a.transaction_id + ",'" + a.community_name + "'," + 
                    a.community_id + ",'" + a.item_name + "'," +
                    a.item_quantity + "," + a.price + ");";

This is the query I am trying to run, the error I get is:

SqliteSyntaxException: near "1": syntax error 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 behavior) Mono.Data.SqliteClient.SqliteCommand.ExecuteDbDataReader (CommandBehavior behavior) System.Data.Common.DbCommand.ExecuteReader () System.Data.Common.DbCommand.System.Data.IDbCommand.ExecuteReader ()

Could use some help

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
Ahsan Imtiaz
  • 295
  • 1
  • 4
  • 16
  • You should really use parameters instead. This code is open for sql injection. – Hypnobrew Apr 09 '16 at 19:50
  • Also, step through your code and put a break point after the sqlQuery variable is populated and before it is executed. Give us the contents of the sqlQuery variable and the issue will probably be a lot more obvious – Dijkgraaf Apr 09 '16 at 20:03

1 Answers1

5

I think you forgot a space in between community_market and VALUES:

sqlQuery = "INSERT INTO community_market " +
"VALUES("+a.transaction_id+",'"+ a.community_name+"',"+ 
a.community_id+",'"+ a.item_name+"',"+ a.item_quantity+","+a.price+");";

Also, SQL Injection may be of some interest.

Community
  • 1
  • 1
AGB
  • 2,230
  • 1
  • 14
  • 21
  • No problem! Glad to help. If this fixed your issue feel free to mark the answer as accepted :-) – AGB Apr 09 '16 at 19:33