I developed an application using vb.net 2003, which contains crystal report, in the code, i gave the parameter values, so that when "report" button is clicked, the report automatically displays itself with given parameter values.however, i opened this application within vb.net 2005, and converted it into a .net 2005 project, after all this, when i run the applicaiton, and click on "report" button, it started asking values for all the parameters, why? plz help
here is the code: (blue-colored area is most likely causing the problem, i checked the outputs of sqlcommands, all fine, seems that somehow the sqlcommands output values are not passed on to the report's parameters)
here is the code: (blue-colored area is most likely causing the problem, i checked the outputs of sqlcommands, all fine, seems that somehow the sqlcommands output values are not passed on to the report's parameters)
VB.NET:
Private Sub btnPrint_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnPrint.Click
Try
If ModuleUser.frmCRCurTestDetails.SqlConnectionGetRptTitleValues.State = ConnectionState.Closed Then
ModuleUser.frmCRCurTestDetails.SqlConnectionGetRptTitleValues.Open()
End If
[COLOR=#339966]'get parameters for title fields [/COLOR]
ModuleUser.frmCRCurTestDetails.SqlCommandGetStartTime.Parameters("@RID").Value = ModuleUser.curResultID
ModuleUser.frmCRCurTestDetails.SqlCommandGetEndTime.Parameters("@RID").Value = ModuleUser.curResultID
ModuleUser.frmCRCurTestDetails.SqlCommandGetTotalMarks.Parameters("@RID").Value = ModuleUser.curResultID
ModuleUser.frmCRCurTestDetails.SqlCommandGetGrade.Parameters("@RID").Value = ModuleUser.curResultID
ModuleUser.frmCRCurTestDetails.SqlCommandGetTName.Parameters("@RID").Value = ModuleUser.curResultID
[COLOR=#339966]'give data to title fields data[/COLOR]
[COLOR=#333399]crystalReportCurResult.SetParameterValue("UNAME", ModuleUser.userName) [/COLOR]
[COLOR=#333399] crystalReportCurResult.SetParameterValue("STARTTIME", ModuleUser.frmCRCurTestDetails.SqlCommandGetStartTime.ExecuteScalar().ToString())
crystalReportCurResult.SetParameterValue("ENDTIME", ModuleUser.frmCRCurTestDetails.SqlCommandGetEndTime.ExecuteScalar().ToString())
crystalReportCurResult.SetParameterValue("TOTALMARKS", ModuleUser.frmCRCurTestDetails.SqlCommandGetTotalMarks.ExecuteScalar().ToString())
crystalReportCurResult.SetParameterValue("GRADE", ModuleUser.frmCRCurTestDetails.SqlCommandGetGrade.ExecuteScalar().ToString())
crystalReportCurResult.SetParameterValue("TNAME", ModuleUser.frmCRCurTestDetails.SqlCommandGetTName.ExecuteScalar().ToString()) [/COLOR]
[COLOR=#339966]'get details fields data[/COLOR]
ModuleUser.frmCRCurTestDetails.SqlSelectCommandGetRptDetailsValues.Parameters("@RID").Value = ModuleUser.curResultID
ModuleUser.frmCRCurTestDetails.DsGetRptDetailsValues.Clear()
ModuleUser.frmCRCurTestDetails.SqlDataAdapterGetRptDetailsValues.Fill(ModuleUser.frmCRCurTestDetails.DsGetRptDetailsValues)
crystalReportCurResult.SetDataSource(ModuleUser.frmCRCurTestDetails.DsGetRptDetailsValues)
[COLOR=#339966]'put report into report view control[/COLOR] ModuleUser.frmCRCurTestDetails.CrystalReportViewerCurTestDetails.ReportSource = crystalReportCurResult
ModuleUser.frmCRCurTestDetails.SqlConnectionGetRptTitleValues.Close()
ModuleUser.frmCRCurTestDetails.Show()
Catch Exp As LoadSaveReportException
MsgBox("Incorrect path for loading report.", _
MsgBoxStyle.Critical, "Load Report Error")
Catch Exp As SqlClient.SqlException
MsgBox(Exp.Message, MsgBoxStyle.Critical, "SQL Error")
Catch Exp As Exception
MsgBox(Exp.Message, MsgBoxStyle.Critical, "General Error")
End Try
End Sub
Last edited: