I have 1 question that'll require multiple answers (I think), because I'm pretty lost on what to do. I'm using Visual Studio 2008 and crystal reports 10 (vb.net web application).
What I am trying to do is check the user who's logged in (I'm using .net users and roles) and assign it as a parameter to a formula in my report. But I also have three parameters that I want the user to input.
Here's my code behind:
Partial Public Class reportstatus
Inherits System.Web.UI.Page
Dim myReport As New CrystalDecisions.CrystalReports.Engine.ReportDocument
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
configureCRYSTALREPORT()
myReport.SetParameterValue("UserName", User.Identity)
End Sub
Private Sub configureCRYSTALREPORT()
Dim myConnectionInfo As New ConnectionInfo()
myConnectionInfo.DatabaseName = "CSi"
myConnectionInfo.UserID = "*****"
myConnectionInfo.Password = "*****"
setDBLOGONforREPORT(myConnectionInfo)
End Sub
Private Sub setDBLOGONforREPORT(ByVal myconnectioninfo As ConnectionInfo)
Dim mytableloginfos As New TableLogOnInfos()
mytableloginfos = CrystalReportViewer1.LogOnInfo
For Each myTableLogOnInfo As TableLogOnInfo In mytableloginfos
myTableLogOnInfo.ConnectionInfo = myconnectioninfo
Next
End Sub
And here's my forumal I'm trying to get to work on my Crystal report:
{tblTireJobs.Status} = {?Status} AND {tblTireJobs.DateReported} >= {?StartDate} AND
{tblTireJobs.DateReported} <= {?EndDate} AND {aspnet_Users.UserId} = {?UserName}
Obviously when it asks for parameters it asks for all 4, including {?UserName}, which I don't want. I want it to take the value from my SetParameter value.
sorry if this is a mess.