C#查询语句还有中文字符查询不到数据 我发布了一个网站,分别在两天服务器上,一台查询查出来有值,,一台查询出来没有值。
请问是什么原因,代码如下
SQL语句是:
string strSql="SELECT ITEM_PROJECT_ID FROM CBRM_ITEM_PROJECT WHERE ACTIVE = 'Y' AND FACTORY_KEY IN(SELECT FACTORY_KEY FROM SBRM_FACTORY WHERE FACTORY_ID IN ('RST TTF')) AND ITEM_PROJECT_ID IN (N'50F86(无LOGO)')";
代码是:
DataTable dt = new DataTable(name);
DbCommand dbCommand = dbProviderFactory.CreateCommand();
dbCommand.Connection = dbConnection;
dbCommand.CommandType = CommandType.Text;
DbDataAdapter dbDataAdapter = dbProviderFactory.CreateDataAdapter();
dbCommand.CommandText = strSql;
dbCommand.CommandTimeout = GetCommandTimeOut();
dbDataAdapter.SelectCommand = dbCommand;
dbDataAdapter.Fill(dt);
return dt;
------解决方案--------------------
N不知道是干什么的吗?
N是表示Unicode编码的字符吧,这样写,没有错的 ------解决方案-------------------- 你这断句有问题,下面的(SELECT FACTORY_KEY FROM SBRM_FACTORY WHERE FACTORY_ID IN ('RST TTF')) ,这里有个括号,说明FACTORY_KEY 值来自这个集合,后边如果是主句的WHERE 条件的话,你括号括一下吧,AND (ITEM_PROJECT_ID IN (N'50F86(无LOGO)')) 试试看。