2006-11-08
Asp.Net2.0 StoredProcedure and Parameter
Dim cn As New SqlConnection("Server=localhost;Database=Northwind;UID=sa;PWD=P@ssw0rd;")
Dim cmd As New SqlCommand("SalesByCategory", cn)
cmd.CommandType = Data.CommandType.StoredProcedure
cmd.Parameters.AddWithValue("@CategoryName", TextBox1.Text)
cn.Open()
Dim dr As SqlDataReader = cmd.ExecuteReader
dr.Read()
Response.Write(dr(0))
dr.Close()
cn.Close()
Dim cmd As New SqlCommand("SalesByCategory", cn)
cmd.CommandType = Data.CommandType.StoredProcedure
cmd.Parameters.AddWithValue("@CategoryName", TextBox1.Text)
cn.Open()
Dim dr As SqlDataReader = cmd.ExecuteReader
dr.Read()
Response.Write(dr(0))
dr.Close()
cn.Close()