Discussion Locked

data class

0 helpful
5 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.
I have a data class which holds all of the resultset fields, but I'm not sure how to get the data from the class and display it outside of the resultset

5 replies

by bbg

I do not work with Java but the logic must be somewhat the same:

dim a variable as type clsData (or whatever the name of it is)
Set the variable as New
Set oData = New clsData

Now you can call the methods of the class to initialize the data.Once done you can access the properties as in:

oData.EmployeeNr

Once done using the object, do not forget to set it to Nothing:
Set oData = Nothing

by okujava

it depends on how do you display the data out of the class. you can override the toString method in the class and return a string containing the values of all fields. it would look like this:
public String toString(){
return field1 + "," + field2;
}
This method should be in the data class. when you call then System.out.println(data); you get the String printed.

the other way would be to access the values of fields either with the fieldnames, if they are public, or with the accessor methods (if there are any. if you could supply a bit of code out of data class, I could tell you more).
it would look like this:
String name = data.getName(); - if you have the accessor methods or
String name = data.name; - if the fields are public.
you should also pay attention to what the datatypes of the fields are...

cheers

This discussion is closed to new replies.