Oracle Connection is closed exception

  • Thread starter Thread starter Josh Shapaka
  • Start date Start date
J

Josh Shapaka

We're having the same issue except it is happening a lot. It seems to come up when many users are trying to perform updates to their forecasts at the same time. Data access code is below:

public static int ExecuteNonQuery(string spName, params OracleParameter[] oracleParams)
{
int affectedRows = -1;
OracleCommand oCmd = new OracleCommand();
oCmd.CommandType = CommandType.StoredProcedure;
oCmd.CommandText = spName;
oCmd.Connection = getConnection();
oCmd.Parameters.AddRange(oracleParams);
try
{
while (oCmd.Connection.State !=
ConnectionState.Open)
{
oCmd.Connection.Open();
}
affectedRows = oCmd.ExecuteNonQuery();
}
finally
{
oCmd.Connection.Close();
}
return affectedRows;
}

Any ideas would be appreciated.

Thanks,
Josh

EggHeadCafe - .NET Developer Portal of Choice
http://www.eggheadcafe.com
 
Back
Top