错误一: 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
解决方法
- 首先将你的 Oracle.ManagedDataAccess.Core 包更新的最新 【这是内部一个bug 修复是在版本19.6以后 所以最好使用最新版本】https://community.oracle.com/tech/developers/discussion/4305076/oracle-manageddataaccess-dll-index-was-outside-the-bounds-of-the-array
- 当你的版本是最新的你还有这个问题 那就跟我一样的情况了 大无语事件: Oracle.ManagedDataAccess 查询是有缓存的 在服务运行期间 数据库表结构发生了改变 与缓存不一致了 查询就会出错 解决这种情况 需要重启服务 或者关闭缓存
参见:https://github.com/oracle/dotnet-db-samples/issues/247
原创文章,作者:,如若转载,请注明出处:https://blog.ytso.com/275754.html