Oracle.ManagedDataAccess.Client 踩坑记录

错误一: Network Transport: TCP transport address connect failure

  • 详细错误信息:Network Transport: TCP transport address connect failureOracle.ManagedDataAccess.Client.OracleException (0x80004005): Network Transport: TCP transport address connect failure
  • 解决方案
    • 首先一定确认你的服务跟你数据库服务的网络是通的 你可以通过telnet验证
    • 其次确认你的connectionString是否正确 ip 地址配置填充是否正确
      Eg: "Data Source=(DESCRIPTION =(ADDRESS = (PROTOCOL = TCP)(HOST ={0})(PORT = {1}))(CONNECT_DATA =(SERVER = DEDICATED)(SERVICE_NAME = {2})));User Id={3};password={4};Connection Timeout ={5};Pooling=true;Max Pool Size=50;Min Pool Size=3;Connection Lifetime=180"
    • 然后确认防火墙关闭
    • 如果以上均正确 那就再配置项追加 "Validate connection=true" or "KeepAlive=true"

错误二:查询datatable 报 Index was outside the bounds of the array

EG:

command.CommandText = "SELECT EID,NOTICETYPE FROM NEWSADMIN.NP_BANK";

using (OracleDataAdapter da = new OracleDataAdapter(command))
{
DataSet ds = new DataSet();
try
{
da.Fill(ds, "ds");//该行报错Index was outside the bounds of the array
cmd.Parameters.Clear();
}
catch (OracleException ex)
{
LogHelper.LogDebug($"QueryData-OracleException:{ex.Message}",ex);
}
finally
{
cmd.Dispose();
//connection.Close();
}
return ds;
}

在执行到 da.Fill(ds, "ds") 时 Oracle.ManagedDataAccess.Client 内部会抛出异常:Index was outside the bounds of the array

解决方法
posted @ 2022-07-20 20:52  C余L小R鱼  阅读(4042)  评论(0编辑  收藏  举报