首先我测试了简单的案例:
cmd.Parameters.Add(new OracleParameter(":paramCode", OracleDbType.NVarchar2)).Value = userCode;
cmd.CommandText = "SELECT * FROM VIEWUSERDATA WHERE Codigo = :paramCode";
cmd.CommandType = System.Data.CommandType.Text;
OracleDataReader reader = cmd.ExecuteReader();
while (reader.Read())
{
//Works, retrieve data
}
其他:
cmd.Parameters.Add(new OracleParameter(":paramRole", OracleDbType.NVarchar2)).Value = userRole;
cmd.CommandText = "SELECT * FROM VIEWUSERDATA WHERE Role = :paramRole";
...
while (reader.Read())
{
//Also works
}
但是加入的时候就不行了。
cmd.Parameters.Add(new OracleParameter(":paramCode", OracleDbType.NVarchar2)).Value = userCode;
cmd.Parameters.Add(new OracleParameter(":paramRole", OracleDbType.NVarchar2)).Value = userRole;
cmd.CommandText = "SELECT * FROM VIEWUSERDATA WHERE Role = :paramRole AND Code = :paramCode";
...
while (reader.Read())//don't retrieve anything
{
}
数据存在,如果我在外部查询编辑器(窗口)中进行查询工作正常。
谢谢。