开发者

OracleDataReader returns wrong value

I can't understand this. The code below always returns zero, even though when I run the same sql in sqlplus, I开发者_运维问答 get the correct value. We just upgraded to Oracle 11g from 10g, and the code worked in 10g. What on earth could be going on?

_Sql = "SELECT Count(ObjectId) FROM AOR_MV_DEV WHERE CASE_NUMBER = 'S101-118'";
OracleCommand _Cmd = new OracleCommand(_Sql, _Cnxn);
_Cmd.CommandText = _Sql;
_reader = _Cmd.ExecuteReader();
_reader.Read();
vColumnValue = _reader.GetDecimal(0);


First, make sure you are using the right data provider for the version of .NET you are running on. That is the most likely culprit.

Other ideas:

Try using ExecuteScalar instead of executereader.

Try selecting 1 from dual: select 1 from dual. See if that returns 1. Then try select count(1) from dual and see if you get 1.

You don't need cmd.CommandText since you're already setting it when you create the command.

Also, you may need to qualify the table name with a schema name.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜