I am using vb and .net user and roles. I can find out who the user is whose logged in by user.identity, which is equal to a field in a table.
Now I have created a crystal report with a wizard because I need to get three parameters from the user (status, start date, end date). Everything works fine if I don't display the results by the user, but I don't know how to get the user into crystal reports.
I use a selection formula in my report, and it shows all 4 parameter inputs when it loads, but I only want the 3 to show (not UserName)
{tblTireJobs.Status} = {?Status} AND {tblTireJobs.DateReported} >= {?StartDate} AND
{tblTireJobs.DateReported} <= {?EndDate} AND {aspnet_Users.UserId} = {?UserName}
I've tried this in my vb code:
myReport.Load("CrystalReport1.rpt")
myReport.SetDatabaseLogon("****", "****")
myReport.SetParameterValue("UserName", User.Identity)
CrystalReportViewer1.ReportSource = myReport
and it will not work. Also I can't write a sql query that will take a User.Identity value because it doesn't exist in crystal reports.
What I am looking for is some help on getting the username (by their login to the web application) and using it to help sort the reults I want to display, because each user is only allowed to view the results that they are allowed to view.
I am a newbie, so pointing me in the right direction would also help.