<%@ Import namespace="System.Data" %>
<%@ Import namespace="System.Data.SqlClient" %>
<html>
<head><title>Using Stored Procedures</title></head>
<body>
<form runat="server" method="post">
<asp:DataGrid id="dgOutput" runat="server" />
</form>
</body>
</html>
<script language="VB" runat="server">
Sub Page_Load(ByVal Source As Object, ByVal E As EventArgs)
' Connection setup
Dim strConnection As String = ConfigurationSettings.AppSettings("NorthWind")
Dim objConnection As New SqlConnection(strConnection)
Dim objCommand As New SqlCommand( _
"[Ten Most Expensive Products]", objConnection)
objCommand.CommandType = CommandType.StoredProcedure
objConnection.Open()
Dim objDataReader As SqlDataReader = objCommand.ExecuteReader()
dgOutput.DataSource = objDataReader
dgOutput.DataBind()
objConnection.Close()
End Sub
</script>
|