Hi all...
I'm very new to crystal report and I have a problem here..
I'm trying to create a program to generate reports using crystal report 8.5 from VB6 with parameter passing.
Have done the linking.. but when I tried running the program, I get the error 'SQL Server not found'
However, everything works fine when I try to preview the report from Crystal Report itself. Below is my code from VB.
Can anyone tell me what's wrong?
Thanks.
Set crptApp = New CRPEAuto.Application
Set crptRpt = crptApp.OpenReport(App.Path & "\test1.rpt"
Set rptDB = crptRpt.Database
Set rptTbls = rptDB.Tables
Set rptTbl = rptTbls.Item(1)
rptTbl.SetLogOnInfo "dsn=reportdb"
Set crptParaFDs = crptRpt.ParameterFields
Set crptParaFD = crptParaFDs.Item(1)
crptParaFD.SetCurrentValue CStr(dtCommFrmDate.Value)
Set crptParaFD = crptParaFDs.Item(2)
crptParaFD.SetCurrentValue CStr(dtCommToDate.Value)
crptRpt.Preview
Set crptParaFD = Nothing
Set crptParaFDs = Nothing
Set crptRpt = Nothing
Set crptApp = Nothing
I'm very new to crystal report and I have a problem here..
I'm trying to create a program to generate reports using crystal report 8.5 from VB6 with parameter passing.
Have done the linking.. but when I tried running the program, I get the error 'SQL Server not found'
However, everything works fine when I try to preview the report from Crystal Report itself. Below is my code from VB.
Can anyone tell me what's wrong?
Thanks.
Set crptApp = New CRPEAuto.Application
Set crptRpt = crptApp.OpenReport(App.Path & "\test1.rpt"
Set rptDB = crptRpt.Database
Set rptTbls = rptDB.Tables
Set rptTbl = rptTbls.Item(1)
rptTbl.SetLogOnInfo "dsn=reportdb"
Set crptParaFDs = crptRpt.ParameterFields
Set crptParaFD = crptParaFDs.Item(1)
crptParaFD.SetCurrentValue CStr(dtCommFrmDate.Value)
Set crptParaFD = crptParaFDs.Item(2)
crptParaFD.SetCurrentValue CStr(dtCommToDate.Value)
crptRpt.Preview
Set crptParaFD = Nothing
Set crptParaFDs = Nothing
Set crptRpt = Nothing
Set crptApp = Nothing