LeighWardle
asked on
VB.NET - using Table Adapters - how to detect when a Table does not exist
Hi Experts,
I have some code that uses Table Adapters like this:
The code works fine as long as the Table (in this case: "TrafficSpectrum") exists.
But it crashes if the Table does not exist.
What Table Adapter property can I use to detect when the Table does not exist?
Regards,
Leigh
I have some code that uses Table Adapters like this:
Dim daLoads5 As LOADSDataSetTableAdapters.TrafficSpectrumTableAdapter
daLoads5 = New LOADSDataSetTableAdapters.TrafficSpectrumTableAdapter
daLoads5.Fill(ds.TrafficSpectrum)
daLoads5.Dispose()
The code works fine as long as the Table (in this case: "TrafficSpectrum") exists.
But it crashes if the Table does not exist.
What Table Adapter property can I use to detect when the Table does not exist?
Regards,
Leigh
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
I believe there is some confusion.
Do you want to know if a table exists IN A DATABASE?
Or do you want to know if a table exists in a DATASET?
Those are two entirely different things.
Do you want to know if a table exists IN A DATABASE?
Or do you want to know if a table exists in a DATASET?
Those are two entirely different things.
When the table doesn't exists in a DATASET then ds.TrafficSpectrum produce a compile error.
ASKER
Hi Scott,
This sequence is the simplest solution:
Try
daLoads6.Fill(ds.HaulRoadT rucks)
Catch ex As Exception
'< feedback to user here>
End Try
Regards,
Leigh
This sequence is the simplest solution:
Try
daLoads6.Fill(ds.HaulRoadT
Catch ex As Exception
'< feedback to user here>
End Try
Regards,
Leigh
Open in new window