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}+"%"
finally i got the answer.. after long-time searching and browse, the solution is that the crystal report formula (maybe i think) can't accept the '%' for 'like' syntax on our sql parameter that passed to crystal report. so i change the '%' to '*' on the formula so it look like :
{sp_employee_report;1.name} like '*'+{?@name}+'*' and
{sp_employee_report;1.address} like '*'+{?@address}+'*'
i hope this could help anyone that has the same problem like i had
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.