From: Dean H. <dea...@dl...> - 2008-01-06 03:39:52
|
Vladislav Panteleev wrote: > But when I run the application and rise the function many > times per minute I've grtting "Timeout exceed" exception write on > conn.Open() method rising. I think this because of I havn't > close the connection and garbage collector do not clean the > memory quickly enought, but I can't to rise conn.Close() You should never rely on the garbage collection to close database connections! > before I return reader. So what should I do to solve this > problem? If you pass CommandBehavior.CloseConnection to the ExecuteReader() method, then the FbDataReader will automatically close the connection when you call it's IDispose.Dispose method. So you can do something like this: using(FbDataReader reader = getReader("blah")) { // Use FbDataReader here } // On this line, FbDataReader will automatically close the connection Dean. |