Wrox Programmer Forums
Pro VB.NET 2002/2003 For advanced Visual Basic coders working .NET version 2002/2003. Beginning-level questions will be redirected to other forums, including Beginning VB.NET.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Pro VB.NET 2002/2003 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
Old December 28th, 2004, 11:29 AM
Authorized User
Join Date: Mar 2004
Posts: 61
Thanks: 0
Thanked 0 Times in 0 Posts
Default Returning Objects

I have a form that has two sub routines. One called Search, another called Change. There is a global variable called m_dsEligData delcared as private and of type DataSet (Private m_dsEligData as dataset).

Search calls the GetData Method in a web service. The web service returns a data set object to m_dsEligData in the sub routine and populates a datagrid with one of the tables in m_dsEligData.

Change access a different table in m_dsEligData and displays data in a datagrid as well.

The problem I'm having is accessing data from the Change Subroutine. I'm successful in accessing tables in Search. However, the Change subroutine tries to access tables in M_dsEligData and it shows that the object still equal Nothing. Why is this happening? Since m_dsEligData is a globabl variable and is being set to the object returned from the Web Service why can't the Change subroutine access data? Please help.
Old January 11th, 2005, 10:22 AM
planoie's Avatar
Friend of Wrox
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts

The problem is that between the first page hit when you call Search() and then next page hit when you call Change(), that variable is reinitialized even though it's global. The variable is indeed global, but only within the context of one page request. Each page request results in a new instance of the page class so you start fresh every time even when you do a postback. The viewstate mechanism of the page and controls are what give the programming model (and user) the perception of a persistant form state.

Similar Threads
Thread Thread Starter Forum Replies Last Post
Returning a recordset John Pennington VB Databases Basics 8 August 18th, 2008 08:37 AM
Returning elements. Neal XSLT 2 May 13th, 2007 04:38 PM
Returning a value Neal XSLT 6 October 13th, 2006 11:41 AM
Returning an Object taipeiben Visual C++ 2005 0 February 17th, 2006 07:24 PM
Function not returning value civa Access 5 January 17th, 2006 03:44 AM

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