passing data sets between objects

  • Thread starter Thread starter Brian Henry
  • Start date Start date
B

Brian Henry

What is the best way to pass a data set between objects? I have a custom
control which will depend on a dataset (kind of like a bound contorl, but im
handleing it differently) is it best to pass as a public variable or a
property? since a property only retrieves By value, and not by reference,
when you send a data set in does it make a copy of it for that object? or
just pass a reference similar to what an array would do in C++. What i need
to do is pass the data set to the custom control, do some updateing on the
data there then have it available for the application behind the contorl
(the parent form). Whats the best way to achieve this? thanks
 
You have the choice :

1) if you declare a private dataset and a property that don't do anything
else than returning and affecting the value like this :

Private _mydata as dataset

Public property mydata() As dataset
set (value as dataset)
_mydata = value
end set
get
return _mydata
end get
end property

You should better use a public value, because a dataset uses a lot of
ressources and you have to use a simple access to your data instead of
calling a method for getting a copy of your value that you'll change after;

2) But if changing your dataset will modify something else in your class;
use properties e.g :

Public property mydata() As dataset
set (value as dataset)
_mydata = value
' call a method or function
end set
....


hope my answer help you;
 
Hi Brian,

What you do with a dataset is not important, you are always passing the
reference, you do not even to return it back.

Cor
 
that is what I thought, I thought it worked like a C array, where no mater
what just passes a reference to the object in memory... thanks for verifying
this
 
Back
Top