Using stored procedure in crystal report 8.5?
I have made a new report using Crystal Reports 8.5 (report1) which uses a stored procedure as its data source. The stored procedure has 2 input parameters (@p1 and @p2) and when I enter some test data for @p1 and @p2 within crystal report IDE , every thing is all right. Then, I added the report1 in visual basic 6.0 IDE and added a new form (form1) and a crystal report viewer control on form1. Now please help me: I wanna to show the report1. What codes exactly should I write to show it?How send data user has entered to the stored procedure paramet开发者_C百科ers via application? I also get this error messsage: the server has not been opened yet"
What's wrong?
Specifying a report
Assumes that SampleReport has been added to your .Net project:
Dim parameter1 As CrystalDecisions.Shared.ParameterField
Dim parameter2 As CrystalDecisions.Shared.ParameterField
With SampleReport
.SetDatabaseLogon("user", "password", "server", "database")
'locate first parameter in report
parameter1 = .ParameterFields.Find("@p1", "")
'locate second parameter in report
parameter2 = .ParameterFields.Find("@p2", "")
End With
'create a new discrete-parameter value
Dim stringValue As New CrystalDecisions.Shared.ParameterDiscreteValue()
stringValue.Value = "USA"
'assign it to the parameter's current values collection
parameter1.CurrentValues.Add(stringValue)
'create a new discrete-parameter value
Dim numberValue As New CrystalDecisions.Shared.ParameterDiscreteValue()
numberValue.Value = 100
'assign it to the parameter's current values collection
parameter2.CurrentValues.Add(numberValue)
With Me.CrystalReportViewer1
.ReportSource = SampleReport
End With
write the below code in vb6
With rptControl
.ReportFileName = "MyCrystalReport1.rpt"
.WindowAllowDrillDown = True
.WindowMaxButton = True
.ParameterFields(0) = "@p1;"& p1Value & ";true"
.ParameterFields(1) = "@p2;"& p2Value & ";true"
.Connect = MyDatabaseConnectionString;
.Action = 1
End With
精彩评论