VB.Net Timeout Error

  • Thread starter Thread starter Mike
  • Start date Start date
M

Mike

I am having a problem with a VB.Net 2.0 Windows application.

When the user selects an item in the lookup box, It uses ADO to
retrieve data into a SQLDataReader, It then bind's this to a data
grid. This works fine normally and the stored procude will take less
than a second to run. I am also closing and disposing the connection
at then end of the task.

Problem comes if you leave the application open for a few minutes not
doing anything then come back to it. When you come back and click the
lookup box or try anthing else which uses ADO in the application, you
get:

Timeout expired. The timeout period elapsed prior to completion of
the operation or the server is not responding.

Can anybody shed any light on this?
 
Hi Mike,
In my view binding data to grid using SQLDataReader will work only with
ASP.NET grid and not with WinForms Grid, Reason why i say is because,
DataReaders are forward only cursors, so it may work well with ASp.NET Grid
and

Since in WinForm grid you can navigate through records up and down, it will
work best with DataSet and not DataReaders.

Try using Dataset instead of DataReaders.

Regards
JIGNESH.
 
Mike said:
I am having a problem with a VB.Net 2.0 Windows application.

When the user selects an item in the lookup box, It uses ADO to
retrieve data into a SQLDataReader, It then bind's this to a data
grid. This works fine normally and the stored procude will take less
than a second to run. I am also closing and disposing the connection
at then end of the task.

Problem comes if you leave the application open for a few minutes not
doing anything then come back to it. When you come back and click the
lookup box or try anthing else which uses ADO in the application, you
get:

Timeout expired. The timeout period elapsed prior to completion of
the operation or the server is not responding.

Can anybody shed any light on this?

From what I understand, when using a SQLDataReader, the connection may
still be open due to the reader has not read all of the records, and it has
to go back and read more records. The connection is still open.

You can use a strong named collection of objects or an ArrayList of objects
with the SQLDataReader, populate an object representing the data, put each
object into a strong named collection or ArrayList and bind the collection
or ArrayList to the control. Or you can use a Dataset, set a Datatable to
the Dataset, and bind the Datatable to the control. In either of the cases,
the data is in memory, as opposed to using a DataReader where the connection
may still be open when bound to the control to read more records.

This is the reason MVP (Model View Presenter) is becoming popular now,
because this eliminates the direct connection or call from the UI to a
database. where as, one has the UI/MVP/Business layer/Data Access layer with
each layer being abstracted from the other or loosely coupled.

They also have the <List> in .Net 2005 too.
 
Back
Top