SqlDataSource Parameterized Stored Procedure Problem!!

Discussion in 'ASP .Net' started by Kel, Jan 5, 2007.

  1. Kel

    Kel Guest

    I am currently trying to pass the SqlDataSource below a paramter set in
    the code-behind (C#) My stored procedure takes one parameter @AID
    varchar(25).

    <asp:SqlDataSource ID="ListEmpSource" Runat="server"
    SelectCommand="dbo.usp_ListEmps"

    ConnectionString="Server=(local);Database=Test;Trusted_Connection=yes"
    SelectCommandType="StoredProcedure" >

    <SelectParameters>
    <asp:parameter Name="AID" Direction="input" Type="string"
    DefaultValue="username" />
    </SelectParameters>

    </asp:SqlDataSource>

    Then in the codebehind I try to do this (one of many solutions I've
    tried)

    string strUserName = User.Identity.Name;

    ListEmpSource.Selecting += new
    SqlDataSourceSelectingEventHandler(ListEmpSource_Selecting);

    //Event Handler:
    public void ListEmpSource_Selecting(object sender,
    SqlDataSourceSelectingEventArgs e)
    {
    e.Command.Parameters["@AID"].Value = strUserName;
    }

    Thanks in advance...
    Kel, Jan 5, 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. Lacka
    Replies:
    2
    Views:
    847
    Lacka
    Dec 31, 2004
  2. David Hearn
    Replies:
    1
    Views:
    1,947
  3. =?Utf-8?B?YmVub2l0?=

    SqlDataSource - Stored Procedure

    =?Utf-8?B?YmVub2l0?=, Dec 20, 2005, in forum: ASP .Net
    Replies:
    1
    Views:
    2,480
  4. michelle
    Replies:
    3
    Views:
    7,049
    Tapio Kulmala
    Feb 14, 2006
  5. Jim Andersen
    Replies:
    3
    Views:
    6,964
    Alex D.
    Mar 3, 2006
Loading...

Share This Page