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)
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
'get parameters for title fields 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
'give data to title fields data
crystalReportCurResult.SetParameterValue("UNAME", ModuleUser.userName) 'get username
crystalReportCurResult.SetParameterValue("STARTTIME", ModuleUser.frmCRCurTestDetails.SqlCommandGetStartTime.ExecuteScalar().ToString()) 'get STARTTIME
crystalReportCurResult.SetParameterValue("ENDTIME", ModuleUser.frmCRCurTestDetails.SqlCommandGetEndTime.ExecuteScalar().ToString()) 'get ENDTIME
crystalReportCurResult.SetParameterValue("TOTALMARKS", ModuleUser.frmCRCurTestDetails.SqlCommandGetTotalMarks.ExecuteScalar().ToString()) 'get TOTALMARKS
crystalReportCurResult.SetParameterValue("GRADE", ModuleUser.frmCRCurTestDetails.SqlCommandGetGrade.ExecuteScalar().ToString()) 'get GRADE
crystalReportCurResult.SetParameterValue("TNAME", ModuleUser.frmCRCurTestDetails.SqlCommandGetTName.ExecuteScalar().ToString()) 'get TNAME
'get details fields data ModuleUser.frmCRCurTestDetails.SqlSelectCommandGetRptDetailsValues.Parameters("@RID").Value = ModuleUser.curResultID
ModuleUser.frmCRCurTestDetails.DsGetRptDetailsValues.Clear()
ModuleUser.frmCRCurTestDetails.SqlDataAdapterGetRptDetailsValues.Fill(ModuleUser.frmCRCurTestDetails.DsGetRptDetailsValues)
crystalReportCurResult.SetDataSource(ModuleUser.frmCRCurTestDetails.DsGetRptDetailsValues)
'put report into report view control 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

crystal report in vb.net problem when converting project from .net 2003 to .net 2005
Jonnnnn
Hey Hey
Musado, how lucky you are that you have a chance to see me some times. Anyway I am giving the solution. I spent a hour and a half to solve this problem. Do not use SetDataSource method after setParameterValue..
True one :
cr.SetDataSource(ds);
cr.SetParameterValue("val_name","value");
Wrong one:
cr.SetParameterValue("val_name","value");
cr.SetDataSource(ds);
I hope it is helpful for your applications
Toni Petrina
miantosca
I tried this, it worked fine:
'give data to title fields data
crystalReportCurResult.SetParameterValue("UNAME", "aaa") 'get username
crystalReportCurResult.SetParameterValue("STARTTIME", "12/12/12") 'get STARTTIME
crystalReportCurResult.SetParameterValue("ENDTIME", "12/12/12") 'get ENDTIME
crystalReportCurResult.SetParameterValue("TOTALMARKS", 100) 'get TOTALMARKS
crystalReportCurResult.SetParameterValue("GRADE", "HD") 'get GRADE
crystalReportCurResult.SetParameterValue("TNAME", "eee") 'get TNAME
I tested the result of sqlcommand, no problem, so it must be the problem when passing the result of sqlcommand to the report's parameter value.
currently working on this, plz help
Dustin Mihalko
thank you caglar you are great, it works.
True one :
cr.SetDataSource(ds);
cr.SetParameterValue("val_name","value");
DPP
coralbird