Hi All,
Please, have a look at the code snippet below:
The temporaryTable gets its contents from a database. It takes several minutes to populate this table, so I decided to fetch the records from the database and keep them in a static table. Subsequent fetch should simply use the static table instead of going to the database. The problem is that once code execution goes from this form to another form and back to this form, the static table would no longer have rows (i.e. staticTable.Rows.Count = 0). The reason for the IF ... End If block is to prevent having to connect to the database when the staticTable has already been populated.Code:Private Function GetRecords() As DataTable Static Dim staticTable As DataTable Dim temporaryTable As New DataTable If Me.Tag.Equals("Static table has not yet been loaded with daily records") Then staticTable = New DataTable 'temporaryTable gets its contents from a database. The code for that is not included here. staticTable = temporaryTable.Copy() Me.Tag = "Static table has been loaded with daily records" End If Return staticTable End Function
Good people of VBForums, please, help!




Reply With Quote
