Solved

Does Dataset already exist

Posted on 2014-02-26
3
343 Views
Last Modified: 2014-02-28
is there any way to tell if a dataset already exists or has been created?  Something like:

ds = dataset

If ds.exists = true then
....
elseif ds.exists = false then
....
End if

Thanks
0
Comment
Question by:Mike_Stevens
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 26

Expert Comment

by:Shaun Kline
ID: 39889842
If your object equates to nothing (ds Is Nothing) then it has not been created. If you need to know if the object has been filled, you can check if the dataset contains any tables, and that the tables have rows.
0
 
LVL 40

Accepted Solution

by:
Jacques Bourgeois (James Burger) earned 500 total points
ID: 39889893
If ds IsNot Nothing Then
   'DataSet has not been created (New was not called)
Else
   If ds.Tables.Count=0 then
      'The DataSet has been created but is empty
   Else
      'The DataSet has been created and contains at least one table
   End If
End If

This being said, do not make the mistake we encounter all over the Internet. If you have only one table, or if you do not use DataRelation objects to create relations between many tables, you do not need a DataSet. It just adds extra overhead. A DataTable object is sufficient in such a case.
0
 

Author Closing Comment

by:Mike_Stevens
ID: 39894587
Excellent help by both!
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

For most people, the WrapPanel seems like a magic when they switch from WinForms to WPF. Most of us will think that the code that is used to write a control like that would be difficult. However, most of the work is done by the WPF engine, and the W…
Entering time in Microsoft Access can be difficult. An input mask often bothers users more than helping them and won't catch all typing errors. This article shows how to create a textbox for 24-hour time input with full validation politely catching …
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial

749 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question