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

Home
ASP.Net
1.ADO.net Database
2.Ajax
3.Asp Control
4.Collections
5.Components
6.Data Binding
7.Development
8.File Directory
9.HTML Control
10.Language Basics
11.Login Security
12.Mobile Control
13.Network
14.Page
15.Request
16.Response
17.Server
18.Session Cookie
19.Sitemap
20.Theme Style
21.User Control and Master Page
22.Validation by Control
23.Validation by Function
24.WebPart
25.WPF
26.XML
ASP.Net » ADO.net Database » Stored Procedure Parameters 




Using Stored Procedures With Parameters: filter

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

<html>
  <head><title>Using Stored Procedures With Parameters</title></head>
  <body>
    <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" />
      <br/><br/>
      <asp:DataGrid id="dgOutput" runat="server" />
    </form>
  </body>
</html>

<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)
  objCommand.Parameters.Add(objParameter)
  objParameter.Direction = ParameterDirection.Input
  objParameter.Value = txtRegion.Text

  objConnection.Open()

  dgOutput.DataSource = objCommand.ExecuteReader()
  dgOutput.DataBind()

  objConnection.Close()
End Sub
</script>
           
       














Related examples in the same category
1.Using Stored Procedures With Output Parameters
2.Using a Built-in Stored Procedure With Parameters
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.