查询DBLink

时间:2018-11-09 18:24:35

标签: c# oracle asp.net-mvc-5

我正在尝试从C#中的OracleDataAdapter执行查询,该查询将转到数据库中可用的DBLink,但是由于某些原因,当它需要填充数据表时,会引发错误:

IndexOutOfRangeException - ndex was outside the bounds of the array

我要执行的代码是:

OracleConnection conn = new OracleConnection(connectionString);
conn.Open();
DataSet dataSet = new DataSet();
OracleCommand cmd = new OracleCommand("select count(*) alive from dual@MYDBLINK");
cmd.CommandType = CommandType.Text;
cmd.Connection = conn;
using (OracleDataAdapter dataAdapter = new OracleDataAdapter())
{
    dataAdapter.SelectCommand = cmd;
    dataAdapter.Fill(dataSet); //Here is where it fails
}

如果在sql developer中执行查询,则该查询有效;如果删除DBLink信息,并将查询设为select count(*) alive from dual,则该代码有效;因此,我想这是DBLink或@的问题字符。

0 个答案:

没有答案