Referencing a common instance of a Dataset

B

bidalah

Hello all,

I am sure there is a simple answer to this question. There just isn't
a simple way to describe it for a search engine.

I have a vb.net program consisting of several windows forms,
miscellanenous classes, and modules. I want all of these classes to
access and update the same instance of an ado dataset and I'm unable
to do it. I thought I could simply create a new instance of the
dataset in a public module. I can't; I still lose all information
storied in the datatable by a child routine as soon as that routine
"returns" to the parent.

Ofcourse I could reference the dataset in every function and
explicitly 'return' it at the end, but that seems unecessarily
complex, particularly since many of the functions that are updating
the dataset are already returning other information. Can anyone tell
me what the procedure is to define a common dataset instance?
 
M

Marina Levit [MVP]

If you had a pointer to that dataset (or any object) in a module, it would
not get lost when any function returned. It sounds like you weren't doing it
right, perhaps posting relevant code would help.
 
B

bidalah

If you had a pointer to that dataset (or any object) in a module, it would
not get lost when any function returned. It sounds like you weren't doing it
right, perhaps posting relevant code would help.









- Show quoted text -

Hi Marina,

Thanks for replying. There isn't much code to see. This is vb.net so
there are no explicit pointers. Following is the basic code:

Module VisualADPVariables
Public VADP_DataSetMain As New VisualADP_Dataset 'Creating a new
instance of my Dataset
End Module


Public Class ConvertFiles
Public EPStoVectorPCL1 as new EPStoVectorPCL 'establishing an
instance of another class

Public Sub ToVectorPCL(ByVal sender As System.Object, ByVal e As
System.EventArgs)

'At this point a table called "STRINGDATA" in the
VADP_Dataset is empty

theVPCLFileName =
EPStoVectorPCL1.PROCESSEPSFORM(FormtoConvert, CurrentSourceDir,
CurrentEditedFinDir, SizeArray(2), SizeArray(3),
CurrentFormScaleFactor_X, CurrentFormScaleFactor_Y)

' the above function populated STRINGDATA with over 1000
rows of data. I have confirmed that this is happening

End Sub ' A count of the rows in VADP_DatasetMain.STRINGDATA
taken here is "0"
End Class
 
B

bidalah

Not "filling" in terms of populating the datatable from a database. I
am determing text data that needs to be used by the program in a later
process and storing it row by row into the dataset until it is used.
My program is doing this perfectly, but when the load routines are
completed and the program returns to the parent routine, the data is
not there.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top