jtylerhill
asked on
Check for the existence of a table within a dataset
Hi,
I'm building a dataset dynamically and the dataset contains several tables (which are named dynamically). Obviously when I try to access the data at a later point, if I reference a table that doesn't exist I will get an error. How can I first check to see if a table exists within the dataset? (e.g. if exists dataset.tables("table1"))
Thanks.
I'm building a dataset dynamically and the dataset contains several tables (which are named dynamically). Obviously when I try to access the data at a later point, if I reference a table that doesn't exist I will get an error. How can I first check to see if a table exists within the dataset? (e.g. if exists dataset.tables("table1"))
Thanks.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
In case anybody needs this in the future, below is how I implemented anv's solution:
Dim x, i As Integer
Dim dt As DataTable
x = MyDataSet.Tables.Count - 1
For i = 0 To x
dt = dsKeys.Tables(i)
If StrComp(dt.TableName(), "MyTableName", CompareMethod.Text) = 0 Then
MsgBox("Table Found")
End If
Next
Thanks again anv!
Dim x, i As Integer
Dim dt As DataTable
x = MyDataSet.Tables.Count - 1
For i = 0 To x
dt = dsKeys.Tables(i)
If StrComp(dt.TableName(), "MyTableName", CompareMethod.Text) = 0 Then
MsgBox("Table Found")
End If
Next
Thanks again anv!
ASKER