Using Stored Procedures With Parameters: filter : Stored Procedure Parameters « Database « ASP.Net

Using Stored Procedures With Parameters: filter

<%@ Import namespace="System.Data" %>
<%@ Import namespace="System.Data.SqlClient" %>

  <head><title>Using Stored Procedures With Parameters</title></head>
    <form runat="server" method="post">
      Enter a State Code:
      <asp:Textbox id="txtRegion" runat="server" />
      <asp:Button id="btnSubmit" runat="server"
                  Text="Search" OnClick="Submit" />
      <asp:DataGrid id="dgOutput" runat="server" />

<script language="VB" runat="server">
Sub Submit(ByVal Source As Object, ByVal E As EventArgs)

  Dim strConnection As String = ConfigurationSettings.AppSettings("NWind")
  Dim objConnection As New SqlConnection(strConnection)
  Dim objCommand As New SqlCommand("sp_CustomersByState", objConnection)
  objCommand.CommandType = CommandType.StoredProcedure

  Dim objParameter As New SqlParameter("@region", SqlDbType.NVarChar, 15)
  objParameter.Direction = ParameterDirection.Input
  objParameter.Value = txtRegion.Text


  dgOutput.DataSource = objCommand.ExecuteReader()

End Sub

Related examples in the same category

1.Using Stored Procedures With Output Parameters
2.Using a Built-in Stored Procedure With Parameters