We help IT Professionals succeed at work.
Get Started

How do I get aspnet_Profile info out in a regular SQL statement?

md0333 asked
Last Modified: 2021-04-21
I have a grid that lists sales. I load the grid with a SQL statement and get the username. Then once I have the username I have to use the ItemDataBound event of the grid and on each row grab the username and use that to get the First and Last name of the user.

Dim userProfile As ProfileBase = ProfileBase.Create(username, True)
userProfile.GetPropertyValue("FirstName") & " " & userProfile.GetPropertyValue("LastName")

This works, but slows down the loading of the grid tremendously. Is there a way in my original SQL statement to retrieve the First and Last Name of the user instead of UserName?

SELECT dbo.Deal.DealNumber, dbo.Customer.DisplayName, dbo.Deal.DealDate, SUM(dbo.DealProduct.Profit) AS Profit, dbo.aspnet_Users.UserName
FROM  dbo.aspnet_Users INNER JOIN
dbo.Deal ON dbo.aspnet_Users.UserId = dbo.Deal.SalesUserID INNER JOIN
dbo.Customer ON dbo.Deal.CustomerID = dbo.Customer.CustomerID INNER JOIN
dbo.DealProduct ON dbo.Deal.DealID = dbo.DealProduct.DealID
Watch Question
Most Valuable Expert 2012
Top Expert 2014
This problem has been solved!
Unlock 1 Answer and 4 Comments.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE