I have a method written in C# that connects to Oracle db, do the work and then call Dispose() in the finally part. However, I got this error:
ORA-02399:exceeded maximum connect time, you are being logged off
When I refresh, I got another error:ORA-01012: not logged on
The third refresh loads the data.
Project is: class library .NET Core 2.1
NugetPackage:Oracle.ManagedDataAccess.Core (2.18.3)
Here is my code
public object GetAllDataByDate(string user, DateTime from,DateTime to, int count=10)
{
if (con.State != ConnectionState.Open)
con.Open();
try
{
return ExtractData(user, from,to, count);
}
catch (Exception ex)
{
return new
{
Error = "Error occured during the extraction of data",
ex.GetType().FullName,
ex.Message,
ex.InnerException
};
}
finally
{
con.Dispose();
}
}
Do I need to call con.Close() also ? or Did I miss something in my code ? Thanks