howto get table from property

aniskhan

Well-known member
Joined
Oct 24, 2005
Messages
90
Location
D.I.Khan
Programming Experience
1-3
i have a class with database operations

now i want a property that can return the data captured in the dataReader.

how to code this property so that it returns the data as arraylist or some thing else...

VB.NET:
ReadOnly Property reader()
        Get
            Dim arr As new ArrayList

            While dataReader.Read
                arr.Add(dataReader.GetString(0))
            End While

            Return arr
        End Get
End Property

suggest a way to get the whole table...Thanx
 
If you want the whole table then why return an ArrayList? Why not return a DataTable. If you know the schema of the table beforehand then you can hardcode that into the method. If you don't know the schema beforehand then you can call GetSchemaTable on the DataReader to get all the information you need to build a DataTable. Once you've done that you can then populate it with the data from the DataReader.
 
Back
Top