OK... that explains it. Thank you everyone,
Karen ----- Original Message ----- From: "Ian Griffiths" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Thursday, May 30, 2002 03:03 Subject: Re: [DOTNET] why does DataSet have to be static meber > Of course what hadn't occurred to me was that you might be doing web forms. > Being a Windows Forms guy, I tend to think of a Windows Forms form when > someone says Form. > > If it's ASP.NET, then no, as a couple of people have pointed out you don't > get the same instance every time. > > > -- > Ian Griffiths > DevelopMentor > > ----- Original Message ----- > From: "Karen Healey" <[EMAIL PROTECTED]> > > > > I can tell its empty because dstMaster is null. I'm really stumped by > this! > > Is there something I should do in the constructor for my class to > initialize > > dstMaster? The only code I have for it is the declaration and the three > > lines of code to copy an existing dataset and merge two others in. And of > > course, the code to access the master which tests for null first. > > > > Thanks, > > > > Karen Healey > > [EMAIL PROTECTED] > > > > > > ----- Original Message ----- > > From: "Ian Griffiths" <[EMAIL PROTECTED]> > > To: <[EMAIL PROTECTED]> > > Sent: Wednesday, May 29, 2002 16:56 > > Subject: Re: [DOTNET] why does DataSet have to be static meber > > > > > > > It sounds like it should be OK. If it's all the one form then it should > > be > > > the same instance. If you wanted to verify that you could print out the > > > value for GetHashcode() in both places. (Use something like > > > Debug.WriteLine, defined in the System.Diagnostics namespace.) If the > > > numbers are the same then that normally means the instance is the same > > > unless GetHashcode has been overridden (and for a form it won't have > been, > > > unless you've overidden it yourself.) If the hash codes are different > you > > > definitely have different instances. > > > > > > How are you determining that the DataSet is empty? (Is the dstMaster > > itself > > > null? Or is it non-null but referring to something that appears to have > > no > > > data in it?) > > > > > > > > > -- > > > Ian Griffiths > > > DevelopMentor > > > > > > ----- Original Message ----- > > > From: "Karen Healey" <[EMAIL PROTECTED]> > > > To: <[EMAIL PROTECTED]> > > > Sent: Wednesday, May 29, 2002 10:49 PM > > > Subject: Re: [DOTNET] why does DataSet have to be static meber > > > > > > > > > > I'm sure the methods are executing in the correct order. But I'm not > > sure > > > > about it being the same instance. It seems to me it should be the > same > > > > instance but I'm new to this. > > > > > > > > I have a multi-panel form (similating multiple pages). At the bottom > of > > > one > > > > of the last panels made visible, I have a finish button. In the > > > > FinishButton_Click method, the current panel is hidden, another panel > is > > > > made visible and the data set is built using the data member, > dstMaster. > > > > Then the user is at the new panel and this panel has a submit button > > (the > > > > finish button is no longer visible). When the user clicks on the > submit > > > > button, the SubmitButton_Click method tries to access dstMaster and > its > > > > empty. Seems like it goes away as soon as the code exits the > > > > FinishButton_Click method. > > > > > > > > So, since this is all one form and no other forms are brought up (just > a > > > > bunch of panels hidden/made visible) then it should be the same > > instance, > > > > right? > > > > > > > > Thanks, > > > > > > > > Karen Healey > > > > [EMAIL PROTECTED] > > > > > > > > ----- Original Message ----- > > > > From: "Ian Griffiths" <[EMAIL PROTECTED]> > > > > To: <[EMAIL PROTECTED]> > > > > Sent: Wednesday, May 29, 2002 16:38 > > > > Subject: Re: [DOTNET] why does DataSet have to be static meber > > > > > > > > > > > > > I have never had any problems using DataSets as non-static members. > I > > > > > suspect that something slightly more subtle is going wrong. Are you > > > > > absolutely sure that (a) the methods are executing in the order you > > > think > > > > > they are and (b) that they are actually executing on the same > instance > > > > both > > > > > times? > > > > > > > > > > > > > > > -- > > > > > Ian Griffiths > > > > > DevelopMentor > > > > > > > > > > ----- Original Message ----- > > > > > From: "Karen Healey" <[EMAIL PROTECTED]> > > > > > > > > > > > I've created a class in C# with a DataSet data member declared > like > > > > this: > > > > > > > > > > > > private DataSet dstMaster; > > > > > > > > > > > > I have a method that builds it by concatenating three datasets > > > together > > > > > > like this: > > > > > > > > > > > > dstMaster = dstOrg.Copy(); > > > > > > dstMaster.Merge( dstContact ); > > > > > > dstMaster.Merge( dstFunding ); > > > > > > > > > > > > In a SEPARATE method, I try to access the contents of the dataset > > but > > > it > > > > > > is empty! > > > > > > > > > > > > If I declare the dataset as static, I don't have this problem. I > > > don't > > > > > > understand why this is necessary. > > > > > > > > > > > > If someone could explain this to me it would be appreciated. > > You can read messages from the DOTNET archive, unsubscribe from DOTNET, or > subscribe to other DevelopMentor lists at http://discuss.develop.com. > You can read messages from the DOTNET archive, unsubscribe from DOTNET, or subscribe to other DevelopMentor lists at http://discuss.develop.com.