B
BenM
I am a novice user of ASP.net, so the following might be trivial for many of
you. I am trying to iterate through a datareader object and add rows to a
table based on the recordset. Here is my code:
ws1_Members.Open()
Dim tmpSQLCmd As New OleDbCommand(tmpSQL, ws1_Members)
Dim tmpMemberReader As OleDbDataReader =
tmpSQLCmd.ExecuteReader(CommandBehavior.CloseConnection)
Dim tmpRow As New TableRow
Dim tmpRowCol As TableRowCollection
Dim tmpCell As New TableCell
While tmpMemberReader.Read
memResultsTable.Visible = True
tmpCell.Text = tmpMemberReader("name") & "<br>" &
tmpMemberReader("cust no")
tmpRow.Cells.Add(tmpCell)
memResultsTable.Rows.Add(tmpRow)
memResultsTable.DataBind()
End While
tmpMemberReader.Close()
ws1_Members.Close()
Theoretically, this should loop through the recordset, creating a new row
for each record. (There should be many rows returned). However, I am only
getting the last record displayed. I have verified my SQL, and it returns
multiple records.
Thanks in advance!
you. I am trying to iterate through a datareader object and add rows to a
table based on the recordset. Here is my code:
ws1_Members.Open()
Dim tmpSQLCmd As New OleDbCommand(tmpSQL, ws1_Members)
Dim tmpMemberReader As OleDbDataReader =
tmpSQLCmd.ExecuteReader(CommandBehavior.CloseConnection)
Dim tmpRow As New TableRow
Dim tmpRowCol As TableRowCollection
Dim tmpCell As New TableCell
While tmpMemberReader.Read
memResultsTable.Visible = True
tmpCell.Text = tmpMemberReader("name") & "<br>" &
tmpMemberReader("cust no")
tmpRow.Cells.Add(tmpCell)
memResultsTable.Rows.Add(tmpRow)
memResultsTable.DataBind()
End While
tmpMemberReader.Close()
ws1_Members.Close()
Theoretically, this should loop through the recordset, creating a new row
for each record. (There should be many rows returned). However, I am only
getting the last record displayed. I have verified my SQL, and it returns
multiple records.
Thanks in advance!