62,046
社区成员
发帖
与我相关
我的任务
分享
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Util;
namespace ConsoleApp17
{
class Program
{
static void Main(string[] args)
{
string connString = @"Data Source=F:\MyDocuments\Downloads\DbPess.db3;Version=3;Cache Size=2000;Pooling=True;Max Pool Size=5;";
string sql = @"SELECT Desc FROM Mesge limit 1";
string str = SQLiteHelper.ExecuteScalar(connString, sql).ToString();
Console.WriteLine(str);
foreach (EncodingInfo eInfo in Encoding.GetEncodings())
{
Encoding ec = Encoding.GetEncoding(eInfo.Name);
byte[] btArr = ec.GetBytes(str);
string strBuffer = Encoding.Default.GetString(btArr);
Console.WriteLine(eInfo.Name+"--->>"+strBuffer);
}
Console.Read();
}
}
}
试了所有的编码, 都不行。update ABC set field_a=N'张三' where Id='8q8wwreqasd'
这样的代码中写大写字母N,来告诉数据库系统不管客户端用什么字符集,你都要让数据接受了不同字符集的命令消息之后,使用 unicode 来更新数据库。
但是许多小的数据库系统,把责任推给了程序员。你必须改变客户端程序的字符集,而不能用你客户端程序默认地字符集方式,来发送 sql 命令。