Visual Studio C#中的Oracle数据适配器

本文关键字:数据 适配器 Oracle 中的 Studio Visual | 更新日期: 2023-09-27 17:58:54

我正在连接Visual Studio 2012(c#)和Oracle 11g。我已经成功地执行了不需要联接属性的查询。但这里有一个我想使用自然联接运行的查询:

comm.CommandText = "select * from friends natural join customer where username='"+username+"' or frnd_username ='"+username+"'";
        ds = new DataSet();
        da = new OracleDataAdapter(comm.CommandText, conn);
        da.Fill(ds, "customer");
        dt = ds.Tables["customer"];

中出现错误

 da.Fill(ds, "customer");

声明,我想这是因为我试图用customer表填充数据集,而不是friends natural join customer。但我也试过了,

da.Fill(ds, "friends natural join customer");

但我还是犯了一个错误。

我得到的错误是"OracleExceptionUnhandled"。上面写着

External component has thrown an exception.

我意识到当查询在SQL中出错时会出现这个错误,但我在SQL中执行了这个查询,它运行得很好。

我尝试更改查询,它在没有自然联接的情况下执行得很好,我很确定这个错误与我填充数据集的表有关。

有人能建议我在括号里写些什么吗。

提前感谢。

Visual Studio C#中的Oracle数据适配器

尝试使用内/左联接更改查询,但问题仍然存在,然后联系您的DBA。

这实际上是一个数据库问题。每次我收到这个错误时,我只需在sql编辑器中检查我的查询,如果它工作正常,我就会联系DBA。

此错误可能是由于-如果任何SQL都不返回行,或者任何其他模式都不存在,或者任何变量变为null并用于进一步计算