简体   繁体   English

Crystal Report Selection Formula无法使用变量

[英]Crystal Report Selection Formula unable to use variable

I am working on the crystal report and I am having some issues with selection formula as I am not able to use variable in the below code. 我正在研究水晶报告,我在选择公式方面遇到了一些问题,因为我无法在下面的代码中使用变量。 However if I, mention the string directly then formula is working 但是,如果我,直接提到字符串然后公式正在工作

Code not working: Dim tb As String= "104" CrystalReport. 代码不起作用:Dim tb As String =“104”CrystalReport。 SelectionFormula= "{table1.tableno}= tb" SelectionFormula =“{table1.tableno} = tb”

Above code is not working and giving a message, string field required, however I have already define my variable 'tb' as string. 上面的代码不起作用并给出一个消息,需要字符串字段,但是我已经将变量'tb'定义为字符串。

Below code is working without using variable: CrystalReport. 下面的代码是在不使用变量的情况下工作的:CrystalReport。 SelectionFormula= "{table1.tableno}= '104' " SelectionFormula =“{table1.tableno} ='104'”

Any help would be greatly appreciated! 任何帮助将不胜感激!

You need to use parameter fields to pass values from your code to crystal reports, check this link it will show you exactly how to do it .. 您需要使用参数字段将值从代码传递到水晶报表,检查此链接它将向您显示如何执行此操作。

edited: you would do that like so.. dtt is a datatable here.. 编辑:你会这样做.. dtt是一个数据表在这里..

CrystalReport1.SetDataSource(dtt)
CrystalReport1.SetParameterValue("param", TextBox1.Text)
CrystalReportViewer1.ReportSource = CrystalReport1
CrystalReportViewer1.Refresh()

I think your code should be: 我认为你的代码应该是:

Dim tb As String= "104"
CrystalReport.SelectionFormula= "{table1.tableno}='" + tb +"'"

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM