Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP.Net 2.0 using stored procedures

Reply
Thread Tools

ASP.Net 2.0 using stored procedures

 
 
Hennie
Guest
Posts: n/a
 
      05-31-2005
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


 
Reply With Quote
 
 
 
 
Brock Allen
Guest
Posts: n/a
 
      05-31-2005
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/aspne...spx#parameters

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

<UpdateParameters>
<asparameter 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
>




 
Reply With Quote
 
 
 
 
=?Utf-8?B?Q293Ym95IChHcmVnb3J5IEEuIEJlYW1lcikgLSBNVlA=?=
Guest
Posts: n/a
 
      05-31-2005
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
>
>
>

 
Reply With Quote
 
Hennie
Guest
Posts: n/a
 
      06-01-2005
Thanks Brock you were a great help.


"Brock Allen" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed) ...
> 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/aspne...spx#parameters
>
> So since those aren't so great, here's a snippet. You'd need to add the
> parameter to the DataSource:
>
> <UpdateParameters>
> <asparameter 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
>>

>
>
>



 
Reply With Quote
 
Hennie
Guest
Posts: n/a
 
      06-01-2005
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" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed) ...
> 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/aspne...spx#parameters
>
> So since those aren't so great, here's a snippet. You'd need to add the
> parameter to the DataSource:
>
> <UpdateParameters>
> <asparameter 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
>>

>
>
>



 
Reply With Quote
 
Brock Allen
Guest
Posts: n/a
 
      06-04-2005
> 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



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Using Stored Procedures with a Grid View =?Utf-8?B?bWltbw==?= ASP .Net 1 01-11-2006 03:50 PM
Urgent problem - Stored Procedures using Created. Tables Mike Hutton ASP .Net 2 07-12-2004 10:40 AM
paging datagrid using stored procedures? Max ASP .Net 2 01-13-2004 02:09 AM
turning Resultsets Using Sql Server Stored Procedures... Amber ASP .Net 0 10-07-2003 03:05 AM
VB.NET Retrieving Identity form MSSQL2000 without using stored procedures Taras ASP .Net 2 10-05-2003 05:35 AM



Advertisments