Wrox Programmer Forums

Need to download code?

View our list of code downloads.

| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
ASP.NET 1.0 and 1.1 Basics ASP.NET discussion for users new to coding in ASP.NET 1.0 or 1.1. NOT for the older "classic" ASP 3 or the newer ASP.NET 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 1.0 and 1.1 Basics section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
 
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old August 4th, 2004, 04:18 PM
Friend of Wrox
 
Join Date: Jun 2003
Location: , , .
Posts: 540
Thanks: 0
Thanked 4 Times in 4 Posts
Default Dataset Question

Hi,

Question: Does a dataset automatically have application scope?

The reason I ask is that I have a dataset that gets filled when the page loads. Then I use that to populate controls. However, the dataset does not automatically get emptied when the page is closed, so this results in double, triple, quadruple, etc. of the same values the next time the page is opened.

I have already resolved the problem by clearing the dataset on page unload, but was just curious as to why this happens. I had assumed it was similar to variables in that they need to be created each time the page loads.

Thanks for any input.

J
  #2 (permalink)  
Old August 4th, 2004, 04:30 PM
planoie's Avatar
Friend of Wrox
Points: 16,481, Level: 55
Points: 16,481, Level: 55 Points: 16,481, Level: 55 Points: 16,481, Level: 55
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Aug 2003
Location: Clifton Park, New York, USA.
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

A dataset is just another variable. I can't imagine how you could be seeing repeated data. Also, you shouldn't need to clear out the dataset. When the dataset's variable goes out of scope (i.e. the page completes processing) the garbage collection system handles the object cleanup. But regardless of this, the variable is no longer "there" so you shouldn't have any residual affects.

Where are you seeing duplicate values? Are you sure this is not some control anomoly? How are you declaring the dataset such that this could happen? Please post some details. Not just to satisfy my curiosity but that there might be a good lesson for others in what you have done to fix it.
  #3 (permalink)  
Old August 4th, 2004, 05:12 PM
Friend of Wrox
 
Join Date: Jun 2003
Location: , , .
Posts: 540
Thanks: 0
Thanked 4 Times in 4 Posts
Default

Hi Peter,

That's exactly what I thought, but this is happening on both my test machine and a completely different server. It only seems to clear out when the server is rebooted, I restart IIS, or if I clear the dataset.

Otherwise, I view the page from several different machines on entirely different networks and each time the data is duplicated by one.

I am seeing the duplicate data when I bind it to a dropdownlist.

Here is some code:

-------------------------------------------------
If Not IsPostBack Then
            'fill the drop downlist
            Dim sql As String
            sql = "SELECT fieldname FROM dbname"
            Load_Dataset(sql, "dsTableName")

            ddlGalName.DataSource = dsApp.Tables("dsTableName").DefaultView
            ddlGalName.DataValueField = "fieldname "
            ddlGalName.DataTextField = "fieldname "
            ddlGalName.DataBind()
End If

------------------------------------------------

Load_Dataset is a sub that I use to fill the dataset table by passing the SQL and name of the table I want to create.

Like I said, everything works fine as long as I clear the dataset on page unload and it does not do it automatically. That is why I asked. It seems to be behaving like an application scope variable.
********************************************

Oh, I just had a brainfart. This dataset is declared in an external module and I am going to take a stab that this is the reason. Would this make it behave that way?

J
  #4 (permalink)  
Old August 5th, 2004, 07:10 AM
planoie's Avatar
Friend of Wrox
Points: 16,481, Level: 55
Points: 16,481, Level: 55 Points: 16,481, Level: 55 Points: 16,481, Level: 55
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Aug 2003
Location: Clifton Park, New York, USA.
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

How is it being declared in this external module? What kind of module is this? That might be the answer.
  #5 (permalink)  
Old August 5th, 2004, 08:23 AM
Friend of Wrox
 
Join Date: Jun 2003
Location: , , .
Posts: 540
Thanks: 0
Thanked 4 Times in 4 Posts
Default

Friend dsApp As DataSet = New DataSet

----------------------------

It is just a VB module where I store Subs, Functions, etc.

...Right-click on your project, add new item, select module.

J
  #6 (permalink)  
Old August 5th, 2004, 02:42 PM
planoie's Avatar
Friend of Wrox
Points: 16,481, Level: 55
Points: 16,481, Level: 55 Points: 16,481, Level: 55 Points: 16,481, Level: 55
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Aug 2003
Location: Clifton Park, New York, USA.
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

Huh... That still doesn't make sense that it's persisting across page hits.
  #7 (permalink)  
Old August 5th, 2004, 02:47 PM
Friend of Wrox
 
Join Date: Jun 2003
Location: , , .
Posts: 540
Thanks: 0
Thanked 4 Times in 4 Posts
Default

Once again, I would have to agree with you, but I can only tell you what I am doing and then leave it to the .Net gods to work their magic.

Not only is it persisting across page hits, it is persisting across different users at different workstations/locations.

J
  #8 (permalink)  
Old August 5th, 2004, 02:52 PM
planoie's Avatar
Friend of Wrox
Points: 16,481, Level: 55
Points: 16,481, Level: 55 Points: 16,481, Level: 55 Points: 16,481, Level: 55
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Aug 2003
Location: Clifton Park, New York, USA.
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

Well, I guess the first thing I would do is get rid of the module. Make a class for common functions and put the dataset in the context it belongs. Put it in the page function, or the page if that is where it needs to be. I have had my own weird problems with globally accessible datasets.
  #9 (permalink)  
Old August 5th, 2004, 03:15 PM
Friend of Wrox
 
Join Date: Jun 2003
Location: , , .
Posts: 540
Thanks: 0
Thanked 4 Times in 4 Posts
Default

Yeah, I will do that. Thanks for the feedback. Things just bug me when they don't work the way they are supposed to.
  #10 (permalink)  
Old December 1st, 2005, 07:05 AM
Authorized User
 
Join Date: Aug 2004
Location: , , .
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
Default

hi,
I'm facing a similar problem.I just wanted to know how you got round that problem.Do you have to populate the dataset everytime the page loads?

Thanks.


 


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Dataset question MaxGay2 VB.NET 2002/2003 Basics 1 November 16th, 2006 10:33 AM
Dataset Designer Question chrislepingwell ADO.NET 0 August 31st, 2006 06:27 AM
Dataset Question Ozymandias VB.NET 2002/2003 Basics 1 November 19th, 2003 12:00 PM



All times are GMT -4. The time now is 01:43 PM.


Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.