Paul Mitton

Hi All

I am simply trying to pass the company name string to my crystal reports. It looks really simple but I must be missing something because it does not work on any report I have tried it on. Below is the code I have tried. The commented out parts are trying to get it to work various ways I have seen on the forum. None of them work.

The parameter seems to be setup corrently because if I try to use "CompanyBlah" instead of "CompanyName" I get a runtime error.

I don't get any errors with the code below but the parameter is not passed as the box asking me to provide input pops up.

Any and all help is greatly appreciated.

Private Function btnDriverStatements_Print()

DriverStatementsReport = New DriverStatements()

Dim pvCompanyName As ParameterDiscreteValue = New ParameterDiscreteValue()

pvCompanyName.Value = "City"

Me.DriverStatementsReport.SetParameterValue("CompanyName", pvCompanyName)

'Me.DriverStatementsReport.SetParameterValue("CompanyName", "City")

Me.DriverStatementsReport.SetDataSource(Me.DsDR)

Me.crvReportViewer.ReportSource = Me.DriverStatementsReport

'Dim crvparaCompanyName As ParameterField

'Dim crvparadvCompanyName As ParameterDiscreteValue = New ParameterDiscreteValue()

'crvparaCompanyName = Me.crvReportViewer.ParameterFieldInfo("CompanyName")

'crvparadvCompanyName.Value = "City Wide"

'crvparaCompanyName.CurrentValues.Add(crvparadvCompanyName)

Me.crvReportViewer.Visible = True

Me.crvReportViewer.RefreshReport()

Return True

End Function

Private Function btnDriverStatements_Print()

DriverStatementsReport = New DriverStatements()

Dim pvCompanyName As ParameterDiscreteValue = New ParameterDiscreteValue()

pvCompanyName.Value = "City"

Me.DriverStatementsReport.SetParameterValue("CompanyName", pvCompanyName)

'Me.DriverStatementsReport.SetParameterValue("CompanyName", "City")

Me.DriverStatementsReport.SetDataSource(Me.DsDR)

Me.crvReportViewer.ReportSource = Me.DriverStatementsReport

'Dim crvparaCompanyName As ParameterField

'Dim crvparadvCompanyName As ParameterDiscreteValue = New ParameterDiscreteValue()

'crvparaCompanyName = Me.crvReportViewer.ParameterFieldInfo("CompanyName")

'crvparadvCompanyName.Value = "City Wide"

'crvparaCompanyName.CurrentValues.Add(crvparadvCompanyName)

Me.crvReportViewer.Visible = True

Me.crvReportViewer.RefreshReport()

Return True

End Function

Private Function btnDriverStatements_Print()

DriverStatementsReport = New DriverStatements()

Dim pvCompanyName As ParameterDiscreteValue = New ParameterDiscreteValue()

pvCompanyName.Value = "City"

Me.DriverStatementsReport.SetParameterValue("CompanyName", pvCompanyName)

'Me.DriverStatementsReport.SetParameterValue("CompanyName", "City")

Me.DriverStatementsReport.SetDataSource(Me.DsDR)

Me.crvReportViewer.ReportSource = Me.DriverStatementsReport

'Dim crvparaCompanyName As ParameterField

'Dim crvparadvCompanyName As ParameterDiscreteValue = New ParameterDiscreteValue()

'crvparaCompanyName = Me.crvReportViewer.ParameterFieldInfo("CompanyName")

'crvparadvCompanyName.Value = "City Wide"

'crvparaCompanyName.CurrentValues.Add(crvparadvCompanyName)

Me.crvReportViewer.Visible = True

Me.crvReportViewer.RefreshReport()

Return True

End Function

Thanks in advance. Paul



Re: Crystal Reports for Visual Studio Passing parameters to Crystal not working. Help.

mewdied

Try commenting out the line Me.crvReportViewer.RefreshReport()





Re: Crystal Reports for Visual Studio Passing parameters to Crystal not working. Help.

Paul Mitton

Hi

I tried that it did not make any difference unfortunately.

Thanks for the idea.

Paul





Re: Crystal Reports for Visual Studio Passing parameters to Crystal not working. Help.

CrystalKeehr

Are you sure that the parameter name in the rpt matches the one you're using in the code (Just a sanity check.)



Re: Crystal Reports for Visual Studio Passing parameters to Crystal not working. Help.

Paul Mitton

Hi

Yes it is. I changed the code to read "CompanyBlah" instead of "CompanyName" and I get a runtime error.

Paul





Re: Crystal Reports for Visual Studio Passing parameters to Crystal not working. Help.

CrystalKeehr

I'm working in C# but the API calls are the same. Here's some simple code that I've tested.

int num = 0;

foreach (Object strParam in arrParams)

{

this.reportDocument1.SetParameterValue(num, strParam);

num++;

}

Where arrParams is an array of parameters. So you should just be able to do a me.blah.SetParameter( 0, "XYZ company"); I believe you are still working with a zero-based system, so the first param should be the 0th param.

Hope this helps.





Re: Crystal Reports for Visual Studio Passing parameters to Crystal not working. Help.

Paul Mitton

Hi

Thanks. But still no joy in mudland.

I tried using the numeric idendifier for the parameter still does not work.

Me.DriverStatementsReport.SetParameterValue(0, "City")

Paul





Re: Crystal Reports for Visual Studio Passing parameters to Crystal not working. Help.

alk0

I'm not sure, but would you try to put '@' before the field name, like "@CompanyName".

ps: I'm using OleDb connection and pass parameters to the OleDbCommand.




Re: Crystal Reports for Visual Studio Passing parameters to Crystal not working. Help.

CrystalKeehr

I'm thinking that Business Objects should put out much more information on how to set parameters.  I've had no end of problems trying to set a variety of parameters (tramp parameters for stored procedures, subreport parameters, tramp parameters in subreports) and I've yet to find any logical pattern.  The sample code is lame because they use named parameters and they don't cover stored procedures. 

The '@' might be appropriate for tramp parameters for stored procedures.  But I've set them without using it too.  Go figure.

Hey Paul:  Could you share your .rpt file with us   That would give us more information.