Using Stored Procedures : Stored Procedure SqlConnection « ADO.net Database « ASP.Net






Using Stored Procedures

<%@ 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>
           
       








Northwind.zip( 736 k)

Related examples in the same category

1.Retrieving Data from a Stored Procedure
2.Call store procedure
3.Call store procedure through SqlConnection
4.Use stored procedure to insert data