Results 1 to 6 of 6

Thread: How to call crystal reports 8.5 from vb 6.0

Threaded View

  1. #1

    Thread Starter
    New Member
    Join Date
    Nov 2005
    Posts
    2

    How to call crystal reports 8.5 from vb 6.0

    Hi there,
    Can anyone help me out,

    I am using crystal reports 8.5 and visual basic 6.0

    I created a report and want to call it using vb6.0 and then show it

    ?How can i do this??
    PS: I tried using crviewer but could not get anything (when i run, either the form is blank and gets hanged up)
    Thanks very much in advance

    I am attaching the code I used :
    VB Code:
    1. Dim CRXApplication As CRAXDDRT20.Application
    2. Dim CRXReport As CRAXDDRT20.report
    3. Dim CRXDatabase As CRAXDDRT20.Database
    4. Dim db As New ADODB.Connection
    5. Dim rs As New ADODB.Recordset
    6.  
    7. Private Sub Form_Load()
    8.     Me.WindowState = 2 'Maximized
    9.  
    10. Set db = New ADODB.Connection
    11.   cnn = "driver=sql server;server=my_server;database=mytest;uid=my_uid;pwd=my_pwd"
    12.    db.Open cnn
    13.     Set rs = New ADODB.Recordset
    14.      rs.Open "select distinct deptic,name,attdic from view_icnotequal where year(attd_date)='2005' and month(attd_date)='09' and dept_id=13", db, adOpenStatic, adLockReadOnly
    15.      
    16.     Set CRXApplication = New CRAXDDRT20.Application
    17.     Set CRXReport = New CRAXDDRT20.report
    18.     Set CRXDatabase = CRXReport.Database
    19.     Set CRXReport = CRXApplication.OpenReport("d:\sarada\testreport1.rpt", 1)
    20.     CRXReport.DiscardSavedData
    21.     CRXReport.Database.Tables(1).SetDataSource rs, 3
    22.      
    23.     CRViewer.ReportSource = CRXReport
    24.     CRViewer.ViewReport
    25.    
    26. '*// Clean up
    27.     Set CRXDatabase = Nothing
    28.     Set CRXReport = Nothing
    29.     Set CRXApplication = Nothing
    30.  
    31. End Sub
    32.  
    33. Private Sub Form_Resize()
    34.     CRViewer.Top = 0
    35.     CRViewer.Left = 0
    36.     CRViewer.Height = ScaleHeight
    37.     CRViewer.Width = ScaleWidth
    38. End Sub
    39.  
    40.  
    41. Private Sub Form_Terminate()
    42.      
    43.     '*// Clean up
    44.     Set CRXDatabase = Nothing
    45.     Set CRXReport = Nothing
    46.     Set CRXApplication = Nothing
    47. End Sub
    thanks very much

    Regards







    Edit: Added [vbcode][/vbcode] tags for clarity. - Hack
    Last edited by Hack; Nov 2nd, 2005 at 06:30 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width