I need a little help enclosed is sample code to fill a gridview.. I have on recordset to get a count of how man time i need to loop through the second record set... which works.. I need help appending data to a gridview when there is mulitple recordsets please advise
Dim sSql As String = "spCount "
sSql = sSql & "'" & Session("sesdtFrom") & "',"
sSql = sSql & "'" & Session("sesdtTo") & "'"
Dim myCommand As New SqlCommand(sSql, conn)
conn.Open()
Dim MyReader As SqlDataReader = command.ExecuteReader()
If MyReader.HasRows Then
Dim i As Integer
For i = 0 To MyReader.FieldCount - 1
Do While MyReader.Read
Dim xSql As String = " exec spGetError "
xSql = xSql & "'" & Session("sesdtFrom") & "',"
xSql = xSql & "'" & Session("sesdtTo") & "',"
xSql = xSql & MyReader("iSiteID")
Dim MyNewCommand As New SqlCommand(xSql, sqlConnection1)
sqlConnection1.Open()
Response.Write(xSql)
Dim MyNewReader As SqlDataReader = MyNewCommand.ExecuteReader()
If MyNewReader.HasRows Then
GridView1.DataSource = MyNewReader
GridView1.DataBind()
End If
MyNewReader.Close()
sqlConnection1.Close()
Loop
Next
Dim sSql As String = "spCount "
sSql = sSql & "'" & Session("sesdtFrom") & "',"
sSql = sSql & "'" & Session("sesdtTo") & "'"
Dim myCommand As New SqlCommand(sSql, conn)
conn.Open()
Dim MyReader As SqlDataReader = command.ExecuteReader()
If MyReader.HasRows Then
Dim i As Integer
For i = 0 To MyReader.FieldCount - 1
Do While MyReader.Read
Dim xSql As String = " exec spGetError "
xSql = xSql & "'" & Session("sesdtFrom") & "',"
xSql = xSql & "'" & Session("sesdtTo") & "',"
xSql = xSql & MyReader("iSiteID")
Dim MyNewCommand As New SqlCommand(xSql, sqlConnection1)
sqlConnection1.Open()
Response.Write(xSql)
Dim MyNewReader As SqlDataReader = MyNewCommand.ExecuteReader()
If MyNewReader.HasRows Then
GridView1.DataSource = MyNewReader
GridView1.DataBind()
End If
MyNewReader.Close()
sqlConnection1.Close()
Loop
Next