The following forum(s) are migrating to a new home on Microsoft Q&A (Preview): Developing Universal Windows apps!

Ask new questions on Microsoft Q&A (Preview).
Interact with existing posts until December 13, 2019, after which content will be closed to all new and existing posts.

Learn More

 none
[UWP][SQL] i can't query include unicode string. RRS feed

  • Question

  • I developing a DB access application with use SQLite.

    but I can't query within unicode string(korean) in select command.

    please refer to below picture.

    and please let me know, how to fix this issue.

    Jack.

    Thursday, June 15, 2017 8:52 AM

Answers

  • Hi jack.hong,

    Could you give me more your query code? Or providing a simple reproduce sample? In my test, I can get the object using other language with the following code in my project. So please make sure you have the object in the sqlite and your query sentence is correct.

                var mylist = conn.Query<User>("select * from User where Username = ?", UserNameTextBox.Text);
                User user=mylist.FirstOrDefault<User>();
                Debug.WriteLine(user.Password);

    Best regards,

    Breeze


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    • Edited by Breeze Liu Monday, June 19, 2017 9:17 AM
    • Marked as answer by jack.hong Friday, July 7, 2017 3:11 AM
    Monday, June 19, 2017 9:17 AM

All replies

  • The first thing I would do is change your queries so that they use parameters, rather than concatenating the query string from variables.
    Thursday, June 15, 2017 2:40 PM
  • Hi jack.hong,

    Could you give me more your query code? Or providing a simple reproduce sample? In my test, I can get the object using other language with the following code in my project. So please make sure you have the object in the sqlite and your query sentence is correct.

                var mylist = conn.Query<User>("select * from User where Username = ?", UserNameTextBox.Text);
                User user=mylist.FirstOrDefault<User>();
                Debug.WriteLine(user.Password);

    Best regards,

    Breeze


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    • Edited by Breeze Liu Monday, June 19, 2017 9:17 AM
    • Marked as answer by jack.hong Friday, July 7, 2017 3:11 AM
    Monday, June 19, 2017 9:17 AM
  • Hi Jack ,

    SQLITE default's installation supports only English if I remember correctly but with Unicode support. The thing is that although you write in Unicode it stores ASCII(I think). I think you will have to do something with pragma.

    http://www.sqlite.org/pragma.html

    Try the encoding

    http://www.sqlite.org/pragma.html#pragma_encoding

    RAGMA encoding; 
    PRAGMA encoding = "UTF-8"; 
    PRAGMA encoding = "UTF-16"; 
    PRAGMA encoding = "UTF-16le"; 
    PRAGMA encoding = "UTF-16be";

    In first form, if the main database has already been created, then this pragma returns the text encoding used by the main database, one of "UTF-8", "UTF-16le" (little-endian UTF-16 encoding) or "UTF-16be" (big-endian UTF-16 encoding). If the main database has not already been created, then the value returned is the text encoding that will be used to create the main database, if it is created by this session.

    The second through fifth forms of this pragma set the encoding that the main database will be created with if it is created by this session. The string "UTF-16" is interpreted as "UTF-16 encoding using native machine byte-ordering". It is not possible to change the text encoding of a database after it has been created and any attempt to do so will be silently ignored.

    Once an encoding has been set for a database, it cannot be changed.

    Databases created by the ATTACH command always use the same encoding as the main database. An attempt to ATTACH a database with a different text encoding from the "main" database will fail.

    I would suggest that create a demo db with a different encoding and do your testings there.

    Friday, June 23, 2017 1:32 PM
  • Hello Jack,

    Is there any update? Do you have got this issue resolved?

    Best regards,

    Breeze


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Monday, June 26, 2017 9:50 AM