locked
how to call crystal reports 8.5 from visual basic 6.0

    Question

  • 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 :
    ---------------------------------------------------------------------------
    Dim CRXApplication As CRAXDDRT20.Application
    Dim CRXReport As CRAXDDRT20.report
    Dim CRXDatabase As CRAXDDRT20.Database
    Dim db As New ADODB.Connection
    Dim rs As New ADODB.Recordset


    Private Sub Form_Load()
        Me.WindowState = 2 'Maximized

    Set db = New ADODB.Connection
      cnn = "driver=sql server;server=my_server;database=mytest;uid=my_uid;pwd=my_pwd"
       db.Open cnn
        Set rs = New ADODB.Recordset
         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
        
        Set CRXApplication = New CRAXDDRT20.Application
        Set CRXReport = New CRAXDDRT20.report
        Set CRXDatabase = CRXReport.Database
        Set CRXReport = CRXApplication.OpenReport("d:\sarada\testreport1.rpt", 1)
        CRXReport.DiscardSavedData
        CRXReport.Database.Tables(1).SetDataSource rs, 3
         
        CRViewer.ReportSource = CRXReport
        CRViewer.ViewReport
       
    '*// Clean up
        Set CRXDatabase = Nothing
        Set CRXReport = Nothing
        Set CRXApplication = Nothing

    End Sub

    Private Sub Form_Resize()
        CRViewer.Top = 0
        CRViewer.Left = 0
        CRViewer.Height = ScaleHeight
        CRViewer.Width = ScaleWidth
    End Sub


    Private Sub Form_Terminate()
        
        '*// Clean up
        Set CRXDatabase = Nothing
        Set CRXReport = Nothing
        Set CRXApplication = Nothing
    End Sub

    thanks very much

    Regards

    Wednesday, November 02, 2005 3:05 AM

Answers

All replies