简体   繁体   English

带有Oracle的.NET(ODP.Net)-无数据

[英].NET with Oracle (ODP.Net) - no data

We have 4 developers in my group and 2 of us can query Oracle data no problem from our .NET 3.5 asp.net webapp. 我们小组中有4位开发人员,我们2位开发人员可以从.NET 3.5 asp.net Webapp上查询Oracle数据。 But the other 2 get no results back, in the same exact query. 但是其他2个在相同的精确查询中没有返回结果。 In their case, if they replace the param with a hardcoded value, they get results back. 在这种情况下,如果将其替换为硬编码值,则可以返回结果。 For example: 例如:

select * from sometable where userid = :userid 从某个表中选择*,其中userid =:userid

(this works for 2 of us, but not the other 2) (这对我们两个人有效,但对其他两个人无效)

select * from sometable where userid = '12345' 从某个表中选择*,其中userid ='12345'

(this works for everyone) (这适用于所有人)

We are all executing the same exact code, same exact query. 我们都在执行相同的精确代码,相同的精确查询。 Any idea why the parameterized query returns nothing for some of us? 知道为什么参数化查询对我们中的某些人什么都不返回吗?

I guarantee you that it has nothing to do with code. 我向您保证,它与代码无关。 On two machines where it doesn't work you either have wrong data access components. 在无法正常工作的两台计算机上,您要么有错误的数据访问组件。 Or, .NET sucks in references to completely wrong objects, which don't break the compilation time but they don't support bind variables. 或者,.NET会吸收对完全错误的对象的引用,这些引用不会中断编译时间,但它们不支持绑定变量。 If you can, check which libraries are loaded into your domain object, it would be clear that you're loading completely wrong libraries. 如果可以,请检查将哪些库加载到您的域对象中,很明显您正在加载完全错误的库。

With-out seeing the code, I think it could be a parameter type issue. 没有看到代码,我认为这可能是参数类型问题。 Oracle is a PIA with parameters. Oracle是具有参数的PIA。 I had issues with DateTime vs TimeStamp before. 我之前在DateTime和TimeStamp方面遇到问题。 Oracle date parameter query not working? Oracle日期参数查询不起作用?

Are you using specific Oracle types? 您是否正在使用特定的Oracle类型?

Are you passing in the same value types every time? 您是否每次都传递相同的值类型? or is one and int and another a double? 还是int和另一个是double?

public IDbDataParameter CreateParameter(IDbCommand cmd, string name, DbType type) {
    OracleParameter p = (OracleParameter)cmd.CreateParameter();
    p.ParameterName = name;
    p.OracleDbType = DBTypeToOracle(type);
    if (p.OracleDbType == OracleDbType.TimeStampLTZ) {
        p.Precision = 3;

    }
    return p;
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM