SQLite.SQLiteAsyncConnection sqlConn = new SQLite.SQLiteAsyncConnection(db_Path, false);
string sql = "SELECT * FROM test where name='中文'";
System.Threading.Tasks.Task<List<model.test>> UserTask = sqlConn.QueryAsync<model.test>(sql);
sqlite 进行中文查询含“中文”的时候报错。英语字母就可以。
错误为:SQLiteClient.SQLiteException: unrecognized token: "'中文的乱码'"
各位大侠 帮帮忙呀
string sql = "SELECT * FROM test where name='中文'";
System.Threading.Tasks.Task<List<model.test>> UserTask = sqlConn.QueryAsync<model.test>(sql);
sqlite 进行中文查询含“中文”的时候报错。英语字母就可以。
错误为:SQLiteClient.SQLiteException: unrecognized token: "'中文的乱码'"
各位大侠 帮帮忙呀
解决方案 »
- 我发了个C#版的Kinect切水果
- 请推荐几款dll加密工具
- c# IsDigit和IsNumber的区别?
- 播放音乐时获得对应歌词??
- 关于Infragistics35.WebUI.UltraWebGrid.ExcelExport.v8.2导出Excel
- 各位大侠,又要麻烦大家啦!在oracle中用什么语句可以修改表的字段名称啊
- vs2012打包失败
- C#WINFORM datagridview输入内容验证
- 这样的“数据汇总”过程怎么处理比较好?
- 请教如何在c#中使用hock,或者是调用哪个API实现hock的功能?
- 安装visual stadio 2010之后wamp搭建起php的环境就用不了
- 正则表达式,小小的一个问题,100分送上
还要如果如果“中文”2个字是你用你写的程序写入的,那么你这样查询读出是没问题的
如果“中文”2个字是你用sqlite数据库管理软件录入,那么你这样查训就会出问题。
反正是你不转换一致的编码的话
sqlite的管理器看着正常的中文数据,VS看着就是乱的
public static extern Result Prepare16_2(IntPtr db, [MarshalAs(UnmanagedType.LPWStr)] string sql, int numBytes, out IntPtr stmt, IntPtr pzTail);
把默认的
public static IntPtr Prepare2 (IntPtr db, string query)
{
IntPtr stmt;
var r = Prepare2 (db, query, query.Length, out stmt, IntPtr.Zero);
if (r != Result.OK) {
throw SQLiteException.New (r, GetErrmsg (db));
}
return stmt;
}改为
public static IntPtr Prepare2(IntPtr db, string query)
{
IntPtr stmt;
int num = System.Text.Encoding.Unicode.GetByteCount(query);
var r = Prepare16_2(db, query, num, out stmt, IntPtr.Zero);
if (r != Result.OK)
{
throw SQLiteException.New(r, GetErrmsg(db));
}
return stmt;
}