Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / ADO.NET / June 2004

Tip: Looking for answers? Try searching our database.

How do you clear a dataset?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
tfs - 30 Jun 2004 11:03 GMT
I have the following code:

The following line is global

Dim sqlDS = New DataSet()

This is in a procedure

    objConnect.Open()
    sqlDA = New SqlDataAdapter("select * from
eventCalendar",objConnect)
    sqlDA.Fill(sqlDS,"eventCalendar")
    Dim totalRows as integer
    Dim totalColumns as integer
    Dim GetRows as DataTable =
sqlDS.tables("eventCalendar")

My problem is that when I do the fill, it seems to be appending to
what was in the old Dataset (sqlDS - Since it is global).

I want to clear the sqlDS before I do the fill.

How would I do this?

Thanks,

Tom.
Cor Ligthert - 30 Jun 2004 11:08 GMT
Hi TFS

sqlDS = nothing
or
dim SqlDS as Dataset
and than in your methode
sqlDs = New Dataset

I hope that helps?

Cor

> I have the following code:
>
[quoted text clipped - 23 lines]
>
> Tom.
Laszlo - 30 Jun 2004 11:11 GMT
Hi,

You can sqlDS.Clear()

Or sqlDS=New DataSet(), then you can a totally new DataSet.

Garbage Collector must delete the old DataSet. (I think, it doesn't make
always.)

Laszlo

> I have the following code:
>
[quoted text clipped - 28 lines]
>     ** SPEED ** RETENTION ** COMPLETION ** ANONYMITY **
> ----------------------------------------------------------
Christoph - 30 Jun 2004 11:12 GMT
> My problem is that when I do the fill, it seems to be appending to
> what was in the old Dataset (sqlDS - Since it is global).
> I want to clear the sqlDS before I do the fill.
> How would I do this?

Couldn't you just do:

sqlDS = New DataSet()

right before the fill?

Chris
Miha Markic [MVP C#] - 30 Jun 2004 11:13 GMT
Hi

Try DataSet.Clear method.

Signature

Miha Markic [MVP C#] - RightHand .NET consulting & development
miha at rthand com
www.rthand.com

> I have the following code:
>
[quoted text clipped - 28 lines]
>     ** SPEED ** RETENTION ** COMPLETION ** ANONYMITY **
> ----------------------------------------------------------
Cor Ligthert - 30 Jun 2004 11:24 GMT
sh.....t
> Try DataSet.Clear method.

I knew there was something with my answer I did put that extra command in
it.

And did not wanted to check it.

:-)

Cor
JohnFol - 30 Jun 2004 11:36 GMT
Try this

sqlDA = New SqlDataAdapter("select * from eventCalendar",objConnect)
If sqlDS.Tables.Contains("eventCalendar") Then
sqlDS.Tables("eventCalendar").Clear()

sqlDA.Fill(sqlDS,"eventCalendar")

> I have the following code:
>
[quoted text clipped - 28 lines]
>     ** SPEED ** RETENTION ** COMPLETION ** ANONYMITY **
> ----------------------------------------------------------
Earl - 30 Jun 2004 17:42 GMT
If you have a global dataset, you will more likely wish to clear the
datatable within the dataset instead of clearing all tables/all data from
the dataset.

sqlDS.tables("eventCalendar").Clear()

> I have the following code:
>
[quoted text clipped - 28 lines]
>     ** SPEED ** RETENTION ** COMPLETION ** ANONYMITY **
> ----------------------------------------------------------

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.