Hello All!
I’m having trouble figuring out a work around for a little problem: First I dimmed the DataAdatpter and DataSet:
Dim DA as ODBCDataAdapter = New ODBCDataAdapter
Dim ds As DataSet = New DataSet
I have the DataAdapter filling the DataTable in my Page_Load sub:
Sub Page_Load(sender As Object, e As EventArgs)
If Not(Page.IsPostBack) Then
DA.SelectCommand = cmdPerv
DA.Fill(ds, “INVOICES”)
conPerv.Close
cmdPerv.Dispose
End If
End Sub
(I use the If Not(Page.IsPostBack) to prevent the table from reloading when other buttons on the form are clicked – ‘Clear Fields’, for example)
Now, I use this DataTable as the DataSource for a Repeater:
rptInv.DataSource = ds.Tables(“INVOICES”).SELECT(strSearch)
rptInv.DataBind()
The above 2 lines of code are in a sub that runs on a button click (not the Page_Load sub).
Problem: while debugging, I find that there is no more table called “INVOICES”, and hence keep getting a System.NullReference error.
I’ve tried referencing the table like ds.Tables(0), and get ‘No Table 0’ error. Also, if I remove the If..Then around the Page_Load sub, it runs fine, but is terribly slow, since it re-fills the DataTable every time a button is clicked.
Any ideas? Thanks in advance.