[dba-VB] Vb.net ADO Equivelent to recordset

John W. Colby jwcolby at colbyconsulting.com
Fri Jul 22 09:21:43 CDT 2005


This 

        While Reader.Read()
            rowVals(0) = Reader("EMPNO")
            rowVals(1) = Reader("JOB_CODE")
            ' Add and return the new row.            
            TypeTable.Rows.Add(rowVals)
        End While

Was what I was looking for.  Apparently the column is the "default property"
for the reader object.  Thus Reader("SomeFldName") is "the same as"
rst("FieldName") from ADO.

It is absolutely insane how much time it takes to get up to speed on a new
object model.

Speaking of which, does anyone have a good source for a hypertext object
model diagram for .net, that shows the object model graphically but allows
drilling down to look at the pieces?

John W. Colby
www.ColbyConsulting.com 

Contribute your unused CPU cycles to a good cause:
http://folding.stanford.edu/

-----Original Message-----
From: dba-vb-bounces at databaseadvisors.com
[mailto:dba-vb-bounces at databaseadvisors.com] On Behalf Of Scott Marcus
Sent: Friday, July 22, 2005 10:14 AM
To: dba-vb at databaseadvisors.com
Subject: RE: [dba-VB] Vb.net ADO Equivelent to recordset


Does this help in any way?

    Private Function GetEmployeeType() As DataTable
        Dim Conn As New SqlConnection(SQLConnStr)
        Dim Cmd As SqlCommand
        Dim Reader As SqlDataReader
        Dim SQL As String
        Dim TypeTable As New DataTable
        Dim empColumn As DataColumn
        Dim KeyColumns(1) As DataColumn
        Dim dvEmployees As DataView
        Dim rowVals(1) As Object

        empColumn = New DataColumn("EMPNO", GetType(String))
        TypeTable.Columns.Add(empColumn)
        KeyColumns(0) = empColumn
        TypeTable.PrimaryKey = KeyColumns
        TypeTable.Columns.Add("TYPE", GetType(Integer))

        'Returns the employee type (8 or 10) for hours in a given week an
employee works per day
        SQL = "SELECT RIGHT('000' + LTRIM(RTRIM(EMPLOYEENO)),4) AS EMPNO,
JOB_CODE FROM TOOL..VISIB.EMPLOYEES WHERE STATUS = 'A' AND (JOB_CODE = '8'
OR JOB_CODE = '10') ORDER BY EMPNO"
        Conn.Open()
        Cmd = New SqlCommand(SQL, Conn)

        Reader = Cmd.ExecuteReader
        While Reader.Read()
            rowVals(0) = Reader("EMPNO")
            rowVals(1) = Reader("JOB_CODE")
            ' Add and return the new row.            
            TypeTable.Rows.Add(rowVals)
        End While
        Conn.Close()
        GetEmployeeType = TypeTable
    End Function
-----Original Message-----
From: dba-vb-bounces at databaseadvisors.com
[mailto:dba-vb-bounces at databaseadvisors.com] On Behalf Of John W. Colby
Sent: Friday, July 22, 2005 10:04 AM
To: dba-vb at databaseadvisors.com
Subject: RE: [dba-VB] Vb.net ADO Equivelent to recordset

Thanks Scott, but I am looking for the equivalent syntax in .NET.  I already
know how to do this in ado in Access.

John W. Colby
www.ColbyConsulting.com 

Contribute your unused CPU cycles to a good cause:
http://folding.stanford.edu/

_______________________________________________
dba-VB mailing list
dba-VB at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/dba-vb
http://www.databaseadvisors.com







More information about the dba-VB mailing list