Question Interesting OO question

faifuhi

New member
Joined
Jan 21, 2009
Messages
2
Programming Experience
3-5
Hi,

I have this application which has one class. I need to return a recordset of data to the calling form. If i use Properties to return, it can only return only a single value at a time. Right now i'm returning a datareader object with one of the properties.

Can anyone suggest a better way to return multiple rows of data to the calling method via Class Property?

Regards,
aHa
 
Just return a DataTable:
VB.NET:
Public Function GetData() As DataTable
    Using connection As New SqlConnection("connection string here")
        Using command As New SqlCommand("SELECT * FROM MyTable", connection)
            connection.Open()

            Using reader As SqlDataReader = command.ExecuteReader()
                Dim table As New DataTable

                table.Load(reader)

                Return table
            End Using
        End Using
    End Using
End Function
 
Back
Top