SQL Reader
Dim cnStr As String =
"Data Source=.;Initial Catalog=Northwind;Integrated Security=true"
Dim cn As New SqlConnection(cnStr)
Dim cmd As New SqlCommand()
cmd.Connection = cn
cmd.CommandText = "select * from region"
cn.Open()
Dim dr As SqlDataReader = cmd.ExecuteReader()
While dr.Read = True
Dim id As Integer = Convert.ToInt32(dr("regionid"))
Dim desc As String = dr.GetString(1)
Response.Write(
String.Format("id: {0} , desc : {1} <br/>", id, desc))
End While
dr.Close()
cn.Close()
"Data Source=.;Initial Catalog=Northwind;Integrated Security=true"
Dim cn As New SqlConnection(cnStr)
Dim cmd As New SqlCommand()
cmd.Connection = cn
cmd.CommandText = "select * from region"
cn.Open()
Dim dr As SqlDataReader = cmd.ExecuteReader()
While dr.Read = True
Dim id As Integer = Convert.ToInt32(dr("regionid"))
Dim desc As String = dr.GetString(1)
Response.Write(
String.Format("id: {0} , desc : {1} <br/>", id, desc))
End While
dr.Close()
cn.Close()