开发环境vs2005,C# winform开发;
数据库oracle10,access2003;
从数据库中读取数据然后拼接成sql,发现部分汉字变成乱码,吃掉了汉字后面一个字符.
但是不是所有,1000条记录,有3-5条拼接后的字符串有乱码.
我是C#新手,各位不吝指教,谢谢了.
数据库oracle10,access2003;
从数据库中读取数据然后拼接成sql,发现部分汉字变成乱码,吃掉了汉字后面一个字符.
但是不是所有,1000条记录,有3-5条拼接后的字符串有乱码.
我是C#新手,各位不吝指教,谢谢了.
ArrayList al = new ArrayList();
string strSqlAcc = "SELECT A0000,A0100,A0101,A0107,A0111,A0121,A0131,A0157,A0174,A0181,C0108,C01SC,C01TC,C01UC,E0104,E0108,E0110,E0112,H01S1,H01S2,H01S5,H01SE,H01SG FROM USRA01";
DbAcc dbaacc = new DbAcc(); OleDbDataReader accdr = dbaacc.GetDataReader(strSqlAcc);
while (accdr.Read())
{
StringBuilder strbf = new StringBuilder("INSERT INTO HJJK_DUIZHAOBIAO(A0000,A0100,A0101,A0107,A0111,A0121,A0131,A0157,A0174,A0181,C0108,C01SC,C01TC,C01UC,E0104,E0108,E0110,E0112,H01S1,H01S2,H01S5,H01SE,H01SG) VALUES");
strbf.Append("(").Append(accdr.GetValue(0).ToString()).Append(",'").Append(accdr.GetValue(1).ToString()).Append("','").Append(accdr.GetValue(2).ToString()).Append("','").Append(accdr.GetValue(3).ToString()).Append("',to_date('").Append(accdr.GetValue(4).ToString()).Append("','yyyy-mm-dd'),'").Append(accdr.GetValue(5).ToString()).Append("','").Append(accdr.GetValue(6).ToString()).Append("','").Append(accdr.GetValue(7).ToString()).Append("','").Append(accdr.GetValue(8).ToString()).Append("','").Append(accdr.GetValue(9).ToString()).Append("','").Append(accdr.GetValue(10).ToString()).Append("','").Append(accdr.GetValue(11).ToString()).Append("','").Append(accdr.GetValue(12).ToString()).Append("','").Append(accdr.GetValue(13).ToString()).Append("','").Append(accdr.GetValue(14).ToString()).Append("',to_date('").Append(accdr.GetValue(15).ToString()).Append("','yyyy-mm-dd'),'").Append(accdr.GetValue(16).ToString()).Append("',to_date('").Append(accdr.GetValue(17).ToString()).Append("','yyyy-mm-dd'),'").Append(accdr.GetValue(18).ToString()).Append("','").Append(accdr.GetValue(19).ToString()).Append("','").Append(accdr.GetValue(20).ToString()).Append("','").Append(accdr.GetValue(21).ToString()).Append("','").Append(accdr.GetValue(22).ToString()).Append("')");
al.Add(strbf.ToString());
Console.Write(strbf.ToString());
Console.WriteLine();
}
accdr.Close();
自己看下MSDN
1,不拼接不会出现乱码
2,如果用+和append拼接出现乱码的记录不通,如果分段查询,乱码出现的行位置也不同