Hi everyone,
I am new to this and trying to generate cystal report dynamically. I am using ttx file and record set for data source. I am not getting any error but not getting anything in report alos, it's blank. I am using subreport in my mail report and that subreport is also create by same rs (same columns and reocrds).
Here is my code..please do advice....
Thanks.
------------------------------------------------------
Private Sub Form_Load()
Dim conn As New ADODB.Connection 'CONNECTION TO BROKER QUERIES
Dim rs As New ADODB.Recordset
Dim appn As New CRAXDRT.Application
Dim rpt As New CRAXDRT.Report
CRViewer1.DisplayBorder = True 'MAKES REPORT FILL ENTIRE FORM
CRViewer1.DisplayTabs = False 'THIS REPORT DOES NOT DRILL DOWN, NOT NEEDED
CRViewer1.EnableDrillDown = False 'REPORT DOES NOT SUPPORT DRILL-DOWN
CRViewer1.EnableRefreshButton = False 'ADO RECORDSET WILL NOT CHANGE, NOT NEEDED
Do While CRViewer1.IsBusy 'ZOOM METHOD DOES NOT WORK WHILE
DoEvents 'REPORT IS LOADING, SO WE MUST PAUSE
Loop
Dim sConnectStr As String
Dim sid, user, passwd As String
sid = "shrd"
user = "tdwived"
passwd = "tdwived"
On Error GoTo ErrorHandler
sConnectStr = "Provider=MSDAORA;Data Source= " & sid & ";User ID=" & user & ";Password=" & passwd & ""
conn.CursorLocation = adUseClient
conn.CommandTimeout = 200
conn.Open sConnectStr
MsgBox "connected"
rs.Open "SELECT ASSET_SEQ_ID,ASSET_STATUS_CODE FROM ASSET WHERE rownum <=2", conn ', adOpenStatic, adLockReadOnly
Set rpt = appn.OpenReport("C:\Project\Rms\Release\Feb-2004\Crystal Report\CrystalReportWithDdtFile.rpt"
MsgBox rs.Fields(1).Value
'rpt.Database.Tables.Item(1).SetLogOnInfo "SHRD.RFC.COM", "", "TDWIVED", "TDWIVED"
'rpt.Database.Tables(1).SetLogOnInfo "", "shrd", "tdwived", "tdwived"
'rpt.DiscardSavedData
rpt.Database.SetDataSource rs, 3, 1
CRViewer1.ReportSource = rpt
CRViewer1.ViewReport
Do While CRViewer1.IsBusy 'ZOOM METHOD DOES NOT WORK WHILE
DoEvents 'REPORT IS LOADING, SO WE MUST PAUSE
Loop 'WHILE REPORT LOADS.
CRViewer1.Zoom (100)
'CRViewer1.PrintReport
'CRViewer1.Visible = True
rs.Close 'ALL BELOW HERE IS CLEANUP
Set rs = Nothing
conn.Close
Set conn = Nothing
' -----------
Exit Sub
ErrorHandler:
MsgBox (Err.Number & ":" & Err.Description)
End Sub
I am new to this and trying to generate cystal report dynamically. I am using ttx file and record set for data source. I am not getting any error but not getting anything in report alos, it's blank. I am using subreport in my mail report and that subreport is also create by same rs (same columns and reocrds).
Here is my code..please do advice....
Thanks.
------------------------------------------------------
Private Sub Form_Load()
Dim conn As New ADODB.Connection 'CONNECTION TO BROKER QUERIES
Dim rs As New ADODB.Recordset
Dim appn As New CRAXDRT.Application
Dim rpt As New CRAXDRT.Report
CRViewer1.DisplayBorder = True 'MAKES REPORT FILL ENTIRE FORM
CRViewer1.DisplayTabs = False 'THIS REPORT DOES NOT DRILL DOWN, NOT NEEDED
CRViewer1.EnableDrillDown = False 'REPORT DOES NOT SUPPORT DRILL-DOWN
CRViewer1.EnableRefreshButton = False 'ADO RECORDSET WILL NOT CHANGE, NOT NEEDED
Do While CRViewer1.IsBusy 'ZOOM METHOD DOES NOT WORK WHILE
DoEvents 'REPORT IS LOADING, SO WE MUST PAUSE
Loop
Dim sConnectStr As String
Dim sid, user, passwd As String
sid = "shrd"
user = "tdwived"
passwd = "tdwived"
On Error GoTo ErrorHandler
sConnectStr = "Provider=MSDAORA;Data Source= " & sid & ";User ID=" & user & ";Password=" & passwd & ""
conn.CursorLocation = adUseClient
conn.CommandTimeout = 200
conn.Open sConnectStr
MsgBox "connected"
rs.Open "SELECT ASSET_SEQ_ID,ASSET_STATUS_CODE FROM ASSET WHERE rownum <=2", conn ', adOpenStatic, adLockReadOnly
Set rpt = appn.OpenReport("C:\Project\Rms\Release\Feb-2004\Crystal Report\CrystalReportWithDdtFile.rpt"
MsgBox rs.Fields(1).Value
'rpt.Database.Tables.Item(1).SetLogOnInfo "SHRD.RFC.COM", "", "TDWIVED", "TDWIVED"
'rpt.Database.Tables(1).SetLogOnInfo "", "shrd", "tdwived", "tdwived"
'rpt.DiscardSavedData
rpt.Database.SetDataSource rs, 3, 1
CRViewer1.ReportSource = rpt
CRViewer1.ViewReport
Do While CRViewer1.IsBusy 'ZOOM METHOD DOES NOT WORK WHILE
DoEvents 'REPORT IS LOADING, SO WE MUST PAUSE
Loop 'WHILE REPORT LOADS.
CRViewer1.Zoom (100)
'CRViewer1.PrintReport
'CRViewer1.Visible = True
rs.Close 'ALL BELOW HERE IS CLEANUP
Set rs = Nothing
conn.Close
Set conn = Nothing
' -----------
Exit Sub
ErrorHandler:
MsgBox (Err.Number & ":" & Err.Description)
End Sub