oysteinkrog / SQLite.Net-PCL

Simple, powerful, cross-platform SQLite client and ORM - Updated version with PCL support
MIT License
353 stars 163 forks source link

[Xamarin.Android] error when executing insert query which contains special characters (german) #348

Closed TomKaminski closed 7 years ago

TomKaminski commented 7 years ago

Hello,

I moved to this library because of Android 7 support, however I can't pass through this error while executing some insert queries.

So...

My insert query looks like this:

INSERT INTO Child (Id, Birthday, City, FirstName, Gender, Info, LastName, LastSync, Street, ZipCode) VALUES (37156784, 1418166000, 'Wien', 'Paul Valentin', 'male', 'Befristung mit 31.08.2011\nAdressänderung 23.6.15\nalte Adresse: testaddress 3/6', 'Kowalsky', 1488877631, 'Böcklinstraße 5353//135', '1020')

Error is following: SQLite.Net.SQLiteException: unrecognized token: "'102"

And the key part is that when I manually replace german characters like ä, ö, ß it starts to work :).

Any ideas where is the problem?

Stack trace: " at SQLite.Net.Platform.XamarinAndroid.SQLiteApiAndroid.Prepare2 (SQLite.Net.Interop.IDbHandle db, System.String query) [0x00037] in <95492c23195c4256b91521f9833f18a1>:0 \n at SQLite.Net.SQLiteCommand.Prepare () [0x0001c] in :0 \n at SQLite.Net.SQLiteCommand.ExecuteNonQuery () [0x00016] in :0 \n at SQLite.Net.SQLiteConnection.Execute (System.String query, System.Object[] args) [0x00044] in :0 \n at LG_Nexera_Outsourcing_Tagesmutter.Backend.DAL.TagesMutterServiceRepository+<>cDisplayClass13_0.b0 (SQLite.Net.SQLiteConnection transactionConnection) [0x00171] in C:\TM\LG-Nexera-Outsourcing-Tagesmutter\LG-Nexera-Outsourcing-Tagesmutter.Backend\DAL\TagesMutterServiceRepository.cs:290 \n at SQLite.Net.Async.SQLiteAsyncConnection+<>cDisplayClass33_0.b0 () [0x0002f] in <2941ec9e51274c81bd357d36a63ba989>:0 \n--- End of stack trace from previous location where exception was thrown ---\n at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] in /Users/builder/data/lanes/3511/77cb8568/source/mono/mcs/class/referencesource/mscorlib/system/runtime/exceptionservices/exceptionservicescommon.cs:143 \n at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) [0x00047] in /Users/builder/data/lanes/3511/77cb8568/source/mono/mcs/class/referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:187 \n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) [0x0002e] in /Users/builder/data/lanes/3511/77cb8568/source/mono/mcs/class/referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:156 \n at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) [0x0000b] in /Users/builder/data/lanes/3511/77cb8568/source/mono/mcs/class/referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:128 \n at System.Runtime.CompilerServices.TaskAwaiter.GetResult () [0x00000] in /Users/builder/data/lanes/3511/77cb8568/source/mono/mcs/class/referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:113 \n at LG_Nexera_Outsourcing_Tagesmutter.Backend.DAL.TagesMutterServiceRepository+d__13.MoveNext () [0x00070] in C:\TM\LG-Nexera-Outsourcing-Tagesmutter\LG-Nexera-Outsourcing-Tagesmutter.Backend\DAL\TagesMutterServiceRepository.cs:274 "

TomKaminski commented 7 years ago

Fixed.

What a shame.

http://stackoverflow.com/a/19489736

10gler commented 7 years ago

:)

guyprovost commented 6 years ago

Well... I have the exact same problem, but when I insert french accentuated characters (like "é" or "à"), the first part of the last value inserted is considered an invalid token.

I know that I should use params queries, but in this special used case... I can't! All I have is an already build up sql statement out of a tool (sqldiff tool). I don't want to start to parse the insert into statement and rebuild it for a parametrized statement.... Why does the statement work whitout foreign characters and fails when using those ?