|
Dear senior prawns, when I was making a report (VB + sql server + crystal report), I encountered a problem.
Report data source I directly use the "database expert" in the crystal report to connect to a stored procedure in my sql server, which has a parameter. Then I assigned the stored procedure parameter in VB and opened the report by the following code:
CRViewer91.ReportSource = Report
Report.DiscardSavedData
Report.ParameterFields.GetItemByName ("@ qinggouID"). ClearCurrentValueAndRange
Report.ParameterFields.GetItemByName ("@ qinggouID"). AddCurrentValue (frm_qinggou.Rep_qgid)
CRViewer91.ViewReport
Screen.MousePointer = vbDefault
After the above code, when I open the report preview, there is a problem: When I first start the VB form and click the "Print" button, when I preview the report, there is no data in the report. But if I close the report and click the "Print" button again, the data can be displayed normally according to the results obtained by the stored process. Everything works fine without closing the VB form. But if I close the VB form, when I run it again, the data will not be displayed for the first time, and the second and subsequent times will be normal. What is the problem? Wait online, anxious me day and night.
Here are my stored procedures:
ALTER proc report_qinggoudan
@qinggouID varchar (30)
as
select A.qg_id, A.qg_date, A.qg_bumen, A.qg_gys, A.qg_enddate, A.qg_gdh, A.qg_bianhao,
A.qg_cpname, A.qg_user, A.qg_master, A.qg_shenhe, B.qg_wl_id, B.qg_wl_name, B.qg_wl_guige, B.qg_wl_qty, B.qg_beizhu
from (select * from sys_qinggou where qg_id = @ qinggouID) as A,
(select * from sys_qinggoumingxi where qg_id = @ qinggouID) as B
where A.qg_id = B.qg_id |
|