Multiple Properties

G

Guest

Dear friends,

How can I create a Class and have multiple I/O porperties.

Example:
At my ASPX.VB I would like to pass

test.ID = "G25"
test.country = "US"

and receive the processed data

response.write test.name
response.write test.address
response.write test.zipcode

Description of what test class need to do:

Public Class test
... I need to pass an ID to be processed by SQL Query
... that is something like this: "Select name,address,zipcode from
customers where id=" & ID & " and country=" & country
...and need to return to my ASPX.VB the result as properties:
... test.name = dbread("name")
... test.address = dbread("address")
... test.zipcode = dbread("zipcode")
end Class
 
K

Ken Dopierala Jr.

Hi,

What I do is create a Fill() function in my class. This function receives a
dataset and reads the first row and fills my class' properties. In some
classes I overload the Fill() function to also accept a specific row number,
the function then uses this row to fill the properties. I don't usually
have the class itself run the query, I create a data access layer that runs
the query. I then take the dataset returned from the data access layer and
pass that to the Fill() function of my class. Good luck! Ken.
 
K

Ken Dopierala Jr.

Hi Robson,

Here is a short example, it doesn't have any exception handling. Good luck!
Ken.

Public Class Person
Private mstrFirstName, mstrLastName As String
Private mintAge as Integer

Public Property FirstName() As String
Get
Return mstrFirstName
End Get
Set(ByVal Value As String)
mstrFirstName = Value
End Set
End Property

Public Property LastName() As String
Get
Return mstrLastName
End Get
Set(ByVal Value As String)
mstrLastName = Value
End Set
End Property

Public Property Age() As Integer
Get
Return mintAge
End Get
Set(ByVal Value As Integer)
mintAge = Value
End Set
End Property

Public Sub FillPerson(ByVal objDS As DataSet)
Dim objDR As DataRow
objDR = objDS.Tables(0).Rows(0)
mstrFirstName = CStr(objDR("FirstName"))
mstrLastName = CStr(objDR("LastName"))
mintAge = CInt(objDR("Age"))
End Sub
End Class
 

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

Members online

Forum statistics

Threads
473,777
Messages
2,569,604
Members
45,217
Latest member
IRMNikole

Latest Threads

Top