Currently logged in user - selectparameter declaration

I am trying to build an sqldatasource using a parameter which I want set to the currently logged in user's username. Any idea how to declare the parameter in the <SelectParameter> tag? ie, my selectstatement is select *** from *** where username = @username... Maybe even if I could declare it in the codebehind using VB using the Membership methods. I am using .net 2.0...
alferAsked:
Who is Participating?
 
HecatonchiresCommented:
asp classic:
Function GetUserName()
      Dim domain_user
      if Request.ServerVariables("LOGON_USER") = "" then
            domain_user = split( "Blah\Admin Must Disable Anonymous Access", "\" )
      else
            domain_user = split(Request.ServerVariables("LOGON_USER"),"\")
      end if
      GetUserName = domain_user(1)
End Function

.net?  really should take the time to learn that.
0
 
craigofcapetownCommented:
"SELECT * FROM tblUsers WHERE user_Name = '" + strUserName + "'"

Where tblUsers is the users' table,
Where user_Name is the username field in the users' table,
Where strUserName is the variable holding the username.

>Function GetUserName()
>     Dim domain_user
>     if Request.ServerVariables("LOGON_USER") = "" then
>          domain_user = split( "Blah\Admin Must Disable Anonymous Access", "\" )
>     else
>          domain_user = split(Request.ServerVariables("LOGON_USER"),"\")
>     end if
>     GetUserName = domain_user(1)
>End Function

then your connection.source would be :

"SELECT * FROM tblUsers WHERE user_Name = '" + GetUserName() + "'"

C
0
 
WMIFCommented:
No comment has been added to this question in more than 21 days, so it is now classified as abandoned.  I will make a recommendation to the moderators on its resolution in a week or two.  I appreciate any comments that would help me to make a recommendation.

Unless it is clear to me that the question has been answered I will recommend delete without refund of points.  It is possible that a Grade less than A will be given if no expert makes a case for an A grade.  It is assumed that any participant not responding to this request is no longer interested in its final disposition.

If the asker does not know how to close the question, the options are here:
http://www.experts-exchange.com/help.jsp#hs5

WMIF
EE Cleanup Volunteer
0
 
WMIFCommented:
No comment has been added to this question in more than 21 days, so it is now classified as abandoned.  I will leave the following recommendation for this question in the Cleanup topic area:
Split - Hecatonchires, craigofcapetown

Any objections should be posted here in the next 4 days.  After that time, the question will be closed.

WMIF
EE Cleanup Volunteer
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.