Crystal Report将存储过程参数从“Like” Sql [英] Crystal Report Passing Stored Procedure Parameter from "Like" Sql

查看:396
本文介绍了Crystal Report将存储过程参数从“Like” Sql的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在将存储过程参数传递给Crystal报表时遇到问题。我试过传递参数,但结果不像我预期的。该参数可以传递,但问题是参数的值必须正好是参数的值。在我的例子中,我想让报告显示喜欢查询的报告,所以参数可以是一个,两个或其他字母的实际价值。



我已经尝试过使用组和记录在选择公式中,但结果是一样的,参数必须是正确的值,并且不能只是字母成员的一部分值。



我的表可能是这样的:

 员工表

id |名称|地址|
-----------------------
01 | Chloe |圣玫瑰|
02 | Ann |圣兰花|

my sql可能有点像这样:

  create proc sp_search 
@name varchar(50),
@address varchar(50)
as
select * from employee where name像'%'+ @ name +'%'
和地址如'%'+ @ address +'%'

我的.net代码用于传递参数,如:

  Sub show_search_employee()
With Me
Dim report as new employee_report
report.SetDataSource(ds)
report.SetParameterValue(@ name,name.text)//名称参数
report.SetParameterValue(@ address ,address.Text)//地址参数
form_employee_report.crv_employee.ReportSource = report //设置报告源
使用
结束End Sub

我的水晶报表公式(我只需双击数据库字段,输入'=',双击参数)

  {sp_employee_report; 1.name} like {?@name} and 
{sp_employee_report; 1.address} like {?@address}

结果可以显示如果name参数和address参数的值完全相同,就像我想显示'01',我必须键入名称和地址'Chloe'和'st。玫瑰'。如果我只是设置名称'C'或地址'玫瑰',没有值显示。我想设置name参数,就像'C'或'Ch'显示第一行,就像's'函数从sql工作。
谢谢您的回覆

解决方案

注意:这不是测试代码 p>

尝试这样

  {sp_employee_report; %+ {?@ address} +%
<%+ {?@ name} +%和
{sp_employee_report; / pre>

I have problems in passing stored procedure parameter to crystal report. I tried passing parameter but the result is not like i expected. the parameter can be passed, but the problem is the value of parameter must be exactly the value of parameter. and in my case, i'd like to make the report that can show the report with "like" query, so the parameter can be one, two, or other letter on the real value.

i've tried use the group and record in selection formula, but the result same, the parameter must exactly the value, and cannot just part of letter member of the value.

my table maybe bit like this :

employee table

id | name | address   | 
-----------------------
01 | Chloe| St. Rose  |
02 | Ann  | St. Orchid|

my sql maybe a bit like this :

create proc sp_search
@name varchar(50),
@address varchar(50)
as
select * from employee where name like '%'+@name+'%' 
and address like '%'+@address+'%'

my .net code for passing parameter like :

Sub show_search_employee()
    With Me
        Dim report As New employee_report
        report.SetDataSource(ds)
        report.SetParameterValue("@name", name.text) //name parameter
        report.SetParameterValue("@address", address.Text) //address parameter
        form_employee_report.crv_employee.ReportSource = report //set report source
    End With
End Sub

my crystal report formula (i just double-click the database field, type '=', and double-click parameter)

{sp_employee_report;1.name} like {?@name} and 
{sp_employee_report;1.address} like {?@address}

the result can be showed if the name parameter and address parameter exactly the value, like if i'd like to show the '01', i must type the name and address 'Chloe' and 'st. rose'. if i just set the name 'C' or the address 'rose', no value showed. i'd like to set the name parameter just like 'C' or 'Ch' to show the first row, just like the 'Like' function from the sql works. Thank you for your reply

解决方案

Note: This is not tested code

Try something like this

{sp_employee_report;1.name} like "%"+{?@name}+"%" and 
{sp_employee_report;1.address} like "%"+{?@address}+"%"

这篇关于Crystal Report将存储过程参数从“Like” Sql的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆