Returning a DataView Object

  • Thread starter Thread starter Roshawn
  • Start date Start date
R

Roshawn

Hi,

It's pretty easy for me to create a function that returns a DataSet object.
But is it possible to create a function that returns a DataView object?

Roshawn
 
Hi Marina,

Are you sure of this, (what am I happy to have the change to write this
after that great mistake with the reference of the dataset).

Maybe it can however is it not a little bit useless?

It would be something in VB.

public function MakeMyDataview(byval ds as dataset, byval selection as
rowfilter, byval mysort as string, byval myrowstate as dataviewrowstate) as
dataview

Which is exactly as one of the overloaded constructors from the dataview.

http://msdn.microsoft.com/library/d...ml/frlrfsystemdatadataviewclassctortopic3.asp

:-)

Cor
 
Sorry, I don't think I am following.

My response was that I just did not see a reason why one couldn't write a
function that returned a DataView (or any other type of object).
 
Hi Marina,

You are right, I should not had connected this to your message, however I am
still ashame about my stupid short mistake from that reference that you saw.

I have placed it again as message to the orginal OP.

:-)

Cor
 
Don't worry, I don't really know which message you are talking about.
Besides, everyone makes mistakes :)
 
Hi,

Sorry for the double post, but I forgot to ask a question. Regarding the
example function provided below:

Public Function MakeMyDataView(ByVal ds As DataSet, ByVal selection As
RowFilter, ByVal mysort As String, ByVal myrowstate as DataViewRowState) As
DataView

'Code would go here
End Function

must I use all of the parameters or can I use only the ones I desire? If
the latter, do I supply empty strings (ie " ") or use the Nothing keyword?

Thanks
Roshawn
 
Roshawn,


just make a function that will return a dataview from the dataset.

dvResults = New Dataview(dsResult.tables(0))

this will give you a dataview for the results in the dataset.

Thanks
Paul
 
But isn't it true that a DataView doesn't actually contain any data, only a
filtered look at the original? And, if so, wouldn't you need to make sure
that the original DataSet remains in scope to wherever the DataView returned
from the function is?
 
Hi Roshawn,

You can use any, however why do you not want to use the standard
constructers there are so much for the dataview that you by making your own
extra procedure are only adding extra instructions.

In my opinion is the only result you will have that you are doubling your
code (which is not important for the processing) howeverm with that making
your program less readable.

Just my thougt

Cor
 
Hi Scott,

In my opinion is this not true (talking about the winform because a webform
class goes totaly out of scope so the dataview exist as well not anymore)

As far as I know will as long as there is a reference to an object that not
be deleted.

Just my thought.

Cor
 
WinForm or WebForm really wouldn't make a difference though to the main
point which is that if you attempt to use a DataView that is based on a
DataTable that is not accessible, won't the DataView no longer have data
either.

Sure WebForms (and their constituent objects) are instanced and removed from
scope more often, but WinForm objects don't remain in scope forever either.
 
Back
Top