ASP.Net 2.0 using stored procedures

H

Hennie

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
 
B

Brock Allen

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;
}
 
G

Guest

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!
***************************
 
H

Hennie

Thanks Brock you were a great help.


Brock Allen said:
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;
}




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
 
H

Hennie

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 said:
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;
}




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
 
B

Brock Allen

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?
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,995
Messages
2,570,226
Members
46,815
Latest member
treekmostly22

Latest Threads

Top