using stored procedure with parameter

Discussion in '.NET' started by sheraz_aries@hotmail.com, Sep 4, 2007.

  1. sheraz_aries@hotmail.com

    sheraz_aries@hotmail.com

    Joined:
    Sep 4, 2007
    Messages:
    3
    Hi

    i am trying to call a stored procedure that contain one parameter (CIty). But for some reason it doesn't display any records ..(i tried the same query in SQL Server Management studio and got the decired record ...so i must be doing something wrong... On the page i have created a textbox and actually thatswhere user enter the city name: the code is given bellow:



    <%@ Page Language="vb" AutoEventWireup="false" CodeBehind="CheckingStoreProcedure.aspx.vb" Inherits="GridView_Checking.CheckingStoreProcedure" %>

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml" >

    <head runat="server">

    <title>Untitled Page</title>
    </head>

    <body>

    <form id="form1" runat="server">

    <div>

    <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:AdventureWorksConnectionString %>"

    SelectCommand="ViewSelectedRecord" SelectCommandType="StoredProcedure">

    <selectParameters >

    <asp:ControlParameter Name ="City" ControlID ="TextBox1" Type=String PropertyName= "text"/>

    </selectParameters>



    </asp:SqlDataSource>



    <asp:TextBox ID="TextBox1" runat="server" Style="left: 11px; position: relative;
    top: -2px"></asp:TextBox>

    <asp:Button ID="Button1" runat="server" Style="left: 60px; position: relative; top: -1px"

    Text="Button" />

    <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" CellPadding="4"

    DataKeyNames="StudentID" DataMember="DefaultView" DataSourceID="SqlDataSource1"

    ForeColor="#333333" GridLines="None" Style="position: relative">





    <FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />

    <Columns>



    <asp:BoundField DataField="StudentID" HeaderText="StudentID" ReadOnly="True" SortExpression="StudentID" />

    <asp:BoundField DataField="FirstName" HeaderText="FirstName" SortExpression="FirstName" />

    <asp:BoundField DataField="LastName" HeaderText="LastName" SortExpression="LastName" />

    <asp:BoundField DataField="Course" HeaderText="Course" SortExpression="Course" />

    <asp:BoundField DataField="Address" HeaderText="Address" SortExpression="Address" />

    <asp:BoundField DataField="YearOfGraduation" HeaderText="YearOfGraduation" SortExpression="YearOfGraduation" />

    <asp:BoundField DataField="City" HeaderText="City" SortExpression="City" />





    </Columns>

    <RowStyle BackColor="#F7F6F3" ForeColor="#333333" />

    <EditRowStyle BackColor="#999999" />

    <SelectedRowStyle BackColor="#E2DED6" Font-Bold="True" ForeColor="#333333" />

    <PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" />

    <HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />

    <AlternatingRowStyle BackColor="White" ForeColor="#284775" />





    </asp:GridView>



    </div>

    </form>
    </body>

    </html>





    Cheers
    Sheraz
     
    sheraz_aries@hotmail.com, Sep 4, 2007
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. raymond chiu
    Replies:
    1
    Views:
    5,727
    Tushar Agarwal
    Jan 21, 2006
  2. Mona
    Replies:
    2
    Views:
    688
    Rajesh Tiwari
    Jun 27, 2003
  3. Mona
    Replies:
    1
    Views:
    915
    Tu-Thach
    Jun 27, 2003
  4. Mike P
    Replies:
    0
    Views:
    3,335
    Mike P
    Jun 19, 2006
  5. Machelle Chandler

    Using query string to pass a value to a stored procedure parameter

    Machelle Chandler, Oct 21, 2003, in forum: ASP .Net Datagrid Control
    Replies:
    0
    Views:
    178
    Machelle Chandler
    Oct 21, 2003
Loading...

Share This Page