| |

VerySource

 Forgot password?
 Register
Search
View: 752|Reply: 3

About the problem that crystal report data cannot be refreshed immediately

[Copy link]

1

Threads

2

Posts

3.00

Credits

Newbie

Rank: 1

Credits
3.00

 China

Post time: 2020-3-2 19:30:02
| Show all posts |Read mode
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
Reply

Use magic Report

0

Threads

3

Posts

2.00

Credits

Newbie

Rank: 1

Credits
2.00

 China

Post time: 2020-7-12 16:30:01
| Show all posts
This is the case, crystal has a cache, I remember there seems to be a refresh function
You test in two steps: (1) Check whether the parameter value of each run is the same
              (2) Enter the parameters to test the crystal report
Anyway, I need to be careful about this job. Two years ago, I could help you immediately, but now I have forgotten it, even if I can’t check the information now.
On your own
Reply

Use magic Report

0

Threads

3

Posts

2.00

Credits

Newbie

Rank: 1

Credits
2.00

 China

Post time: 2020-7-12 17:00:01
| Show all posts
Also, this problem is not a problem of stored procedures, as long as the sql side is tested, it has nothing to do with the stored procedure
Reply

Use magic Report

1

Threads

2

Posts

3.00

Credits

Newbie

Rank: 1

Credits
3.00

 China

 Author| Post time: 2020-7-15 17:30:01
| Show all posts
Because the data source is set in the database expert of Crystal Reports when the report is being built, if the stored procedure is selected, it automatically asks you to enter a parameter value (my stored procedure has only one parameter), so I chose a null value. Is it because of this reason that every time the program is started, the first time the report is loaded, it uses the default value, which is a null value?
Reply

Use magic Report

You have to log in before you can reply Login | Register

Points Rules

Contact us|Archive|Mobile|CopyRight © 2008-2023|verysource.com ( 京ICP备17048824号-1 )

Quick Reply To Top Return to the list