Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Context.User.Identity.Name

Status
Not open for further replies.

tkikkert

IS-IT--Management
Jan 6, 2004
9
US
I have created a login page and everything works fine. Now I want to do a select in a GridView based on the userid matching Context.User.Identity.Name. I've tried every way I can think of to create the select and most of the times I get an error - 'the server tag is not well formed'. I've tried many combinations of the following:

SelectCommand="SELECT [EmpName] FROM [Expenses] WHERE [UserName]= '" + currentUserID + "'"

or

SelectCommand="SELECT [EmpName] FROM [Expenses] WHERE [UserName]= '" + Context.User.Identity.Name + "'"

If I actually put a username in, it works fine. Any help would be appreciated.

Thanks
 
start by using a parameterized query, not injected sql. the error doesn't match the code. This usually means the displayed error is a side effect of an other error.

Jason Meckley
Programmer
Specialty Bakers, Inc.
 
Thanks for the reply Jason. I actually managed to Google about using parameters. If I put a DefaultValue in the parameter, it works fine but I can't figure out how to load the context.user.Identy.Name into the parameter. I assume it has to be done in a sub. Could you give me an example of how you would do this in vb?
 
Found the solution to my problem. Thanks again, Jason.
 
please post what you found so it may help someone else with the same problem in the future.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top