2006-11-08
Asp.Net2.0 DataReader
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs)
Dim cn As New SqlConnection("Server=localhost;Database=Northwind;UID=sa;PWD=P@ssw0rd;")
Dim cmd As New SqlCommand("select * from employees", cn)
cn.Open()
Dim dr As SqlDataReader = cmd.ExecuteReader
Do While dr.Read
Response.Write(dr("LastName") & "
")
Loop
dr.Close()
cn.Close()
End Sub
Protected Sub Button2_Click(ByVal sender As Object, ByVal e As System.EventArgs)
Dim cn As New SqlConnection("Server=localhost;Database=Northwind;UID=sa;PWD=P@ssw0rd;")
Dim cmd As New SqlCommand("select * from employees;select * from products", cn)
cn.Open()
Dim dr As SqlDataReader = cmd.ExecuteReader
Do
Do While dr.Read
Response.Write(dr(0) & " -- " & dr(1) & "
")
Loop
Response.Write("
")
Loop While dr.NextResult
dr.Close()
cn.Close()
End Sub
Dim cn As New SqlConnection("Server=localhost;Database=Northwind;UID=sa;PWD=P@ssw0rd;")
Dim cmd As New SqlCommand("select * from employees", cn)
cn.Open()
Dim dr As SqlDataReader = cmd.ExecuteReader
Do While dr.Read
Response.Write(dr("LastName") & "
")
Loop
dr.Close()
cn.Close()
End Sub
Protected Sub Button2_Click(ByVal sender As Object, ByVal e As System.EventArgs)
Dim cn As New SqlConnection("Server=localhost;Database=Northwind;UID=sa;PWD=P@ssw0rd;")
Dim cmd As New SqlCommand("select * from employees;select * from products", cn)
cn.Open()
Dim dr As SqlDataReader = cmd.ExecuteReader
Do
Do While dr.Read
Response.Write(dr(0) & " -- " & dr(1) & "
")
Loop
Response.Write("
")
Loop While dr.NextResult
dr.Close()
cn.Close()
End Sub