C#连接远程oracles数据库 中文做条件查询不到数据
夜_麒麟 2017-07-02 05:56:32 客户端环境 windows7 32
本机注册表字符集
AMERICAN_AMERICA.US7ASCII
客户端 环境变量字符集 AMERICAN_AMERICA.US7ASCII
远程oracle 服务端 通过本地plsql 查询出 字符集为AMERICAN_AMERICA.US7ASCII
那么问题来了 本机通过PLSQL 连接远程数据库 查询如:
select * from temp where name='中国' 是可以查询到数据的
通过C# 程序就查询不到数据了
下面附上 代码
string conn = "Provider=OraOLEDB.Oracle;Data Source=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=服务器地址)(PORT=1521)))(CONNECT_DATA=(SID=ORCL)(SERVER=DEDICATED)));User Id=oracle;Password=oracle;Persist Security Info=True;Unicode=True;";
string sql =string.Format("select * from temp where name='中国' ");
using (OleDbDataAdapter da = new OleDbDataAdapter(SQL, conn))
{
try
{
DataSet ds = new DataSet();
da.Fill(ds);
dataGridView1.DataSource = ds.Tables[0];
}
catch (OleDbException exp)
{
da.Dispose();
throw new Exception(exp.Message);
}
}