oracle / dotnet-db-samples

.NET code samples for Oracle database developers #OracleDotNet
http://otn.oracle.com/dotnet
MIT License
408 stars 190 forks source link

Oracle.ManagedDataAccess.dll Index was outside the bounds of the array #247

Closed xiaoxiaomemg closed 1 year ago

xiaoxiaomemg commented 2 years ago

Hello!

Im using Oracle.ManagedDataAccess.Core v3.21.50 C# and getting error when trying to select data from DB

For example:

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

using (OracleDataAdapter da = new OracleDataAdapter(command)) { DataSet ds = new DataSet(); try { da.Fill(ds, "ds"); cmd.Parameters.Clear(); } catch (OracleException ex) { LogHelper.LogDebug($"QueryData-OracleException:{ex.Message}",ex); } finally { cmd.Dispose(); //connection.Close(); } return ds; }

Error message is "Index was outside the bounds of the array." And error code-" da.Fill(ds, "ds");"

alexkeh commented 2 years ago

What DB version are you using? What data types are EID and NOTICETYPE?

Does the problem happen all the time, such as selecting zero rows, one row, and many rows? Does it require one of the data types to be of a particular size or have some particular characteristic?

If you can enable ODP.NET tracing and share that, it will speed up the diagnosis.

xiaoxiaomemg commented 2 years ago

What DB version are you using? What data types are EID and NOTICETYPE?

Does the problem happen all the time, such as selecting zero rows, one row, and many rows? Does it require one of the data types to be of a particular size or have some particular characteristic?

If you can enable ODP.NET tracing and share that, it will speed up the diagnosis.

My Db version is Oracle Database 12c Enterprise Edition Release 12.2.0.1.0 - 64bit Production; And the EID and NOTICETYPE have the same data type with string. EID is the key.In addition to this, they don't have other particular characteristic.

The problem hasppens occasionally, but once the problem appear, it will be often. I have to restart this to slove the problem quickly , so I can't support the tracing now.(Restarted can temporarily slove thisproblem )

alexkeh commented 2 years ago

The ODP.NET trace would be most informative.

I've seen this type of error before when the table definition changes between queries. The cause is the statement cache that retains the metadata no longer accurately represents the table. The solution is turn off statement caching. Of course, that situation is rare since few apps perform DDL on their schema objects while their apps on running.

alexkeh commented 1 year ago

I need more info to further investigate the problem. I will close this for now until I can get a trace or something else that could direct us to the root cause.

xiaoxiaomemg commented 1 year ago

Thank you for your reply, It's indeed because the table structure has changed.