ASP.Net 2.0 using stored procedures

Discussion in 'ASP .Net' started by Hennie, May 31, 2005.

  1. Hennie

    Hennie Guest

    Hi

    Can anybody point me to good articles or sites on using stored proc's in a
    grid or details view in ASP2.0
    Also how can I return the username of the current logged in user as a
    parameter value in a stored proc?
    i.e. @UpdatedBy.value = LoginName
    I am using the wizard in asp.net 2.0

    Many thanks
    Hennie, May 31, 2005
    #1
    1. Advertising

  2. Hennie

    Brock Allen Guest

    You can pass parameters using the new declarative data source model. The
    ASP.NET quickstarts touches on this, so it's not as in depth of a sample
    that I'd like to give:

    http://beta.asp.net/QUICKSTART/aspnet/doc/data/advanced.aspx#parameters

    So since those aren't so great, here's a snippet. You'd need to add the parameter
    to the DataSource:

    <UpdateParameters>
    <asp:parameter Name="UpdateBy" Type="String" />
    </UpdateParameters>

    And since there's no <asp:CurrentUser> parameter, you'll have to manually
    set this one in Page_Load:

    protected void Page_Load(object sender, EventArgs e)
    {
    SqlDataSource1.UpdateParameters["UpdatedBy"].DefaultValue = User.Identity.Name;
    }

    -Brock
    DevelopMentor
    http://staff.develop.com/ballen



    > Hi
    >
    > Can anybody point me to good articles or sites on using stored proc's
    > in a
    > grid or details view in ASP2.0
    > Also how can I return the username of the current logged in user as a
    > parameter value in a stored proc?
    > i.e. @UpdatedBy.value = LoginName
    > I am using the wizard in asp.net 2.0
    > Many thanks
    >
    Brock Allen, May 31, 2005
    #2
    1. Advertising

  3. The wizards are different, but the basic principles are the same as the 1.x
    Framework:

    To get a user name, the user must be logged in. This can be done by turning
    off anonymous access, which forces a user login. If the user is on your
    network, the admins can set it up so they do not have to use the login box.

    To get the parameter into the rest of the system, you will have to store it
    somewhere. The easiest is session.

    --
    Gregory A. Beamer
    MVP; MCP: +I, SE, SD, DBA

    ***************************
    Think Outside the Box!
    ***************************


    "Hennie" wrote:

    > Hi
    >
    > Can anybody point me to good articles or sites on using stored proc's in a
    > grid or details view in ASP2.0
    > Also how can I return the username of the current logged in user as a
    > parameter value in a stored proc?
    > i.e. @UpdatedBy.value = LoginName
    > I am using the wizard in asp.net 2.0
    >
    > Many thanks
    >
    >
    >
    =?Utf-8?B?Q293Ym95IChHcmVnb3J5IEEuIEJlYW1lcikgLSBN, May 31, 2005
    #3
  4. Hennie

    Hennie Guest

    Thanks Brock you were a great help.


    "Brock Allen" <> wrote in message
    news:...
    > You can pass parameters using the new declarative data source model. The
    > ASP.NET quickstarts touches on this, so it's not as in depth of a sample
    > that I'd like to give:
    >
    > http://beta.asp.net/QUICKSTART/aspnet/doc/data/advanced.aspx#parameters
    >
    > So since those aren't so great, here's a snippet. You'd need to add the
    > parameter to the DataSource:
    >
    > <UpdateParameters>
    > <asp:parameter Name="UpdateBy" Type="String" />
    > </UpdateParameters>
    >
    > And since there's no <asp:CurrentUser> parameter, you'll have to manually
    > set this one in Page_Load:
    >
    > protected void Page_Load(object sender, EventArgs e)
    > {
    > SqlDataSource1.UpdateParameters["UpdatedBy"].DefaultValue =
    > User.Identity.Name;
    > }
    >
    > -Brock
    > DevelopMentor
    > http://staff.develop.com/ballen
    >
    >
    >
    >> Hi
    >>
    >> Can anybody point me to good articles or sites on using stored proc's
    >> in a
    >> grid or details view in ASP2.0
    >> Also how can I return the username of the current logged in user as a
    >> parameter value in a stored proc?
    >> i.e. @UpdatedBy.value = LoginName
    >> I am using the wizard in asp.net 2.0
    >> Many thanks
    >>

    >
    >
    >
    Hennie, Jun 1, 2005
    #4
  5. Hennie

    Hennie Guest

    Another question

    How can I get the unique ID of the user? I want to store the details of the
    last person who edited a record on the DB. By just adding the name I might
    get duplicate names.

    Thanks

    "Brock Allen" <> wrote in message
    news:...
    > You can pass parameters using the new declarative data source model. The
    > ASP.NET quickstarts touches on this, so it's not as in depth of a sample
    > that I'd like to give:
    >
    > http://beta.asp.net/QUICKSTART/aspnet/doc/data/advanced.aspx#parameters
    >
    > So since those aren't so great, here's a snippet. You'd need to add the
    > parameter to the DataSource:
    >
    > <UpdateParameters>
    > <asp:parameter Name="UpdateBy" Type="String" />
    > </UpdateParameters>
    >
    > And since there's no <asp:CurrentUser> parameter, you'll have to manually
    > set this one in Page_Load:
    >
    > protected void Page_Load(object sender, EventArgs e)
    > {
    > SqlDataSource1.UpdateParameters["UpdatedBy"].DefaultValue =
    > User.Identity.Name;
    > }
    >
    > -Brock
    > DevelopMentor
    > http://staff.develop.com/ballen
    >
    >
    >
    >> Hi
    >>
    >> Can anybody point me to good articles or sites on using stored proc's
    >> in a
    >> grid or details view in ASP2.0
    >> Also how can I return the username of the current logged in user as a
    >> parameter value in a stored proc?
    >> i.e. @UpdatedBy.value = LoginName
    >> I am using the wizard in asp.net 2.0
    >> Many thanks
    >>

    >
    >
    >
    Hennie, Jun 1, 2005
    #5
  6. Hennie

    Brock Allen Guest

    > How can I get the unique ID of the user? I want to store the details
    > of the last person who edited a record on the DB. By just adding the
    > name I might get duplicate names.


    You mean User.Identity.Name doesn't work? So this means you have many users
    in your user database with the same logon name?

    -Brock
    DevelopMentor
    http://staff.develop.com/ballen
    Brock Allen, Jun 4, 2005
    #6
    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. Taras
    Replies:
    2
    Views:
    4,810
    Rick Spiewak
    Oct 5, 2003
  2. Elliot M. Rodriguez, MCSD

    Re: crystal reports and asp.net stored procedures

    Elliot M. Rodriguez, MCSD, May 21, 2004, in forum: ASP .Net
    Replies:
    0
    Views:
    471
    Elliot M. Rodriguez, MCSD
    May 21, 2004
  3. .Net Sports
    Replies:
    3
    Views:
    602
    Robbe Morris [C# MVP]
    May 12, 2005
  4. Pedro Vera
    Replies:
    5
    Views:
    437
    Juan T. Llibre
    Mar 30, 2007
  5. Dragonhunter

    Are stored procedures practical using ASP only?

    Dragonhunter, Sep 12, 2003, in forum: ASP General
    Replies:
    10
    Views:
    238
    mark4asp
    Sep 14, 2003
Loading...

Share This Page