VB6, RDC, ODBC, SQL Server
This is probably very easy, I'm just new to RDC (been using OCX for years)
I have a VERY simple report using ODBC, based on a stored proc with 1 char param. It works fine in the Crystal Designer.
In VB6, I add the viewer to a form and add this code:
Private Sub Form_Load()
Dim app As CRAXDRT.Application
Dim myReport As CRAXDRT.Report
Set app = New CRAXDRT.Application
Set myReport = app.OpenReport("c:\work\xtest.rpt"
myReport.Database.Tables(1).SetLogOnInfo "MyDSN", "MyTable", "sa", "MyPwd"
myReport.ParameterFields(1).AddCurrentValue "TheValue"
myReport.EnableParameterPrompting = False
CRViewer1.ReportSource = myReport
Form2.WindowState = vbMaximized
Form2.Show
myReport.DiscardSavedData
CRViewer1.ViewReport
End Sub
No error occurs, but the report shows no data. The stored procedure is being passed NULL instead of "TheValue" (I did a trace to confirm).
What am I doing wrong?
Note: If I don't set EnableParameterPrompting = False, then crystal prompts for the value and if I type it in, it gets passed properly. (again, confirmed with trace)
This is probably very easy, I'm just new to RDC (been using OCX for years)
I have a VERY simple report using ODBC, based on a stored proc with 1 char param. It works fine in the Crystal Designer.
In VB6, I add the viewer to a form and add this code:
Private Sub Form_Load()
Dim app As CRAXDRT.Application
Dim myReport As CRAXDRT.Report
Set app = New CRAXDRT.Application
Set myReport = app.OpenReport("c:\work\xtest.rpt"
myReport.Database.Tables(1).SetLogOnInfo "MyDSN", "MyTable", "sa", "MyPwd"
myReport.ParameterFields(1).AddCurrentValue "TheValue"
myReport.EnableParameterPrompting = False
CRViewer1.ReportSource = myReport
Form2.WindowState = vbMaximized
Form2.Show
myReport.DiscardSavedData
CRViewer1.ViewReport
End Sub
No error occurs, but the report shows no data. The stored procedure is being passed NULL instead of "TheValue" (I did a trace to confirm).
What am I doing wrong?
Note: If I don't set EnableParameterPrompting = False, then crystal prompts for the value and if I type it in, it gets passed properly. (again, confirmed with trace)