I am trying to cache a table adapter.... I've done something similar with a string, so I know I'm on the right track, but I'm just not getting the OOP of how to assign it.
I looked here, but it isn't using a tableadapter:
The error I'm getting occurs the second time I hit the code AFTER it's been assigned:
Exception Details: System.InvalidCastExceptio
n: Unable to cast object of type 'FeaturesDataTable' to type 'System.Data.DataSet'.
Line 102: Dim DataGridCache As DataSet = CType(Cache.Get("DataGridC
The problem is somewhere here, I'm not assigning it a Dataset. And if I need to make it something else, I don't know what I need to make it:
e", GridView1.DataSource, Nothing, _
Someone else could probably look at this and see it in a second.
Protected Sub GetFeatureCache()
'Programmatic Caching Setup
Dim DataGridCache As DataSet = CType(Cache.Get("DataGridCache"), DataSet)
'Check if Cache item is equal to Nothing
If DataGridCache Is Nothing Then
Dim IAdapter2 As New IDataSetTableAdapters.FeaturesTableAdapter()
Dim features As IDataSet.FeaturesDataTable
features = IAdapter2.GetFeatures
GridView1.DataSource = features
'insert ito cache, expire in 1 day
Cache.Insert("DataGridCache", GridView1.DataSource, Nothing, _
GridView1.DataSource = DataGridCache