473,396 Members | 2,036 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

ASP.Net 2.0 using stored procedures

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
Nov 19 '05 #1
5 1417
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>
<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


Nov 19 '05 #2
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

Nov 19 '05 #3
Thanks Brock you were a great help.
"Brock Allen" <ba****@NOSPAMdevelop.com> wrote in message
news:83**********************@msnews.microsoft.com ...
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>
<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


Nov 19 '05 #4
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" <ba****@NOSPAMdevelop.com> wrote in message
news:83**********************@msnews.microsoft.com ...
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>
<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


Nov 19 '05 #5
> 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

Nov 19 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

10
by: Dragonhunter | last post by:
Hello, The aspfaq.com seems to really push stored procedures, and I hear the same advice here all the time. So I want to take the advice. Is it possible to create and practically maintain,...
2
by: Yves Touze | last post by:
Hi All, I'm trying to migrate from SQL Server 7.0 to SQL Server 2000. I've got some ASP page which call VB components that retrieve shaped recordsets from SQL Server using the MSDATASHAPE...
18
by: Robin Lawrie | last post by:
Hi again, another problem! I've moved from an Access database to SQL server and am now having trouble inserting dates and times into seperate fields. I'm using ASP and the code below to get the...
5
by: gilles27 | last post by:
I've ready many of the posts on this and other newsgroups in which people describe working practices for source control of database scripts. We are looking to implement something similar in my...
2
by: scott | last post by:
Hi, Just wondering what sort of problems and advantages people have found using stored procedures. I have an app developed in VB6 & VB.NET and our developers are starting to re-write some of the...
10
by: serge | last post by:
Using "SELECT * " is a bad practice even when using a VIEW instead of a table? I have some stored procedures that are identical with the difference of one statement in the WHERE clause. If I...
2
by: Kent Lewandowski | last post by:
hi all, Recently I wrote some stored procedures using java jdbc code (admittedly my first stab) and then tried to implement the same within java packages (for code reuse). I encountered...
0
by: Amber | last post by:
Stored procedures are faster and more efficient than in-line SQL statements. In this article we will look at two SQL Server stored procedures; one using an input parameter and one not, and see how...
45
by: John | last post by:
Hi When developing vb.bet winform apps bound to sql server datasource, is it preferable to use SELECTs or stored procedure to read and write data from/to SQL Server? Why? Thanks Regards
2
by: pascal.baetscher | last post by:
Hello everyone, I face currently a problem where I could need some input for searching the source of the Problem System: SQL Server 9.0 I fill from Database A with triggers Database B,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.