MySQL server version for the right syntax to use near '1` WHERE `Capacity` = @Capacity' at line 1

I get this error when i attempt to save a 1700 objects using Save().

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ‘1WHERECapacity` = @Capacity’ at line 1

if i inspect the dbConnection object i see this in LastCommandText

“SELECT Capacity, Count FROM List1WHERECapacity` = @Capacity

This is the stack trace. Any ideas??

Unhandled Exception: MySql.Data.MySqlClient.MySqlException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '1WHERECapacity= @Capacity' at line 1 at MySql.Data.MySqlClient.MySqlStream.ReadPacket() at MySql.Data.MySqlClient.NativeDriver.GetResult(Int32& affectedRow, Int64& insertedId) at MySql.Data.MySqlClient.Driver.GetResult(Int32 statementId, Int32& affectedRows, Int64& insertedId) at MySql.Data.MySqlClient.Driver.NextResult(Int32 statementId, Boolean force) at MySql.Data.MySqlClient.MySqlDataReader.NextResult() at MySql.Data.MySqlClient.MySqlCommand.ExecuteReader(CommandBehavior behavior) at MySql.Data.MySqlClient.MySqlCommand.ExecuteDbDataReader(CommandBehavior behavior) at System.Data.Common.DbCommand.System.Data.IDbCommand.ExecuteReader() at ServiceStack.OrmLite.OrmLiteCommand.ExecuteReader() at ServiceStack.OrmLite.OrmLiteReadCommandExtensions.ExecReader(IDbCommand dbCmd, String sql) at ServiceStack.OrmLite.OrmLiteResultsFilterExtensions.ConvertTo[T](IDbCommand dbCmd, String sql) at ServiceStack.OrmLite.OrmLiteReadCommandExtensions.SingleById[T](IDbCommand dbCmd, Object value) at ServiceStack.OrmLite.OrmLiteWriteCommandExtensions.Save[T](IDbCommand dbCmd, T obj) at ServiceStack.OrmLite.OrmLiteWriteApi.<>c__DisplayClass23_01.b__0(IDbCommand dbCmd)
at ServiceStack.OrmLite.OrmLiteExecFilter.Exec[T](IDbConnection dbConn, Func2 filter) at ServiceStack.OrmLite.OrmLiteReadExpressionsApi.Exec[T](IDbConnection dbConn, Func2 filter)
at ServiceStack.OrmLite.OrmLiteWriteApi.Save[T](IDbConnection dbConn, T obj, Boolean references)

No idea, what’s the class definition you’re trying to save and what do you mean by saving 1700 objects? in a row using a foreach?

My bad… I was passing dbConnection.Save() a list when i used SaveAll() it worked.

It was a very strange error could not find it anywhere with google.

1 Like