Quantcast
Channel: Active questions tagged utf-8 - Stack Overflow
Viewing all articles
Browse latest Browse all 1060

C# post string to sqlilte in utf8 encoding

$
0
0

I post data which contains Ö and Ş not correctly posted to sqlite. I share a small part of my code in debug state.

queryString = "INSERT INTO "+ LOCALDB_USER_TABLE_NAME +" (Username, UpdateTime, IpAddr, Synced) VALUES ('"+                userName +"', '"+ timestamp +"', '"+ IPAddr +"', '"+ synced +"')";                _sourceDB.ExecuteNonQuery(queryString);

I open immediate window in visual studio and simply type these. Here I add Ş and Ü characters in utf8 to insert statement manually.

INSERT INTO adusers (Username, UpdateTime, IpAddr, Synced) VALUES ('CŞŞŞŞŞööööÖÜÜÜb', '2015-11-17T19:16:39.859434200Z', '192.168.0.7', '1')

I search smilar problems in stackoverflow and try this in i.w.:

byte[] bytes = System.Text.Encoding.Default.GetBytes(queryString);Expression has been evaluated and has no valuequeryString = System.Text.Encoding.UTF8.GetString(bytes);

and here how query string looks like in immediate window:

INSERT INTO adusers (Username, UpdateTime, IpAddr, Synced) VALUES ('CSSSSS��������b', '2015-11-17T19:16:39.859434200Z', '192.168.0.7', '1')

Data row in sqlite studio looks like same also so this is the problem (I can add utf8 character to sqlite database in studio). Something I mus do and query string should post data sqlilte with correct characters in utf8.


Viewing all articles
Browse latest Browse all 1060

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>