View Single Post
  #1 (permalink)  
Old February 2nd, 2005, 11:54 PM
mycha_2003 mycha_2003 is offline
Registered User
 
Join Date: Feb 2005
Location: singapore, , .
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default crystal report export using vb6

i am using vb6 crystal report 9, i want create a report to view the screen and automaticall export pdf , or excel , i am using the following Code.
    Dim conn As ADODB.Connection
    Dim Rs As ADODB.Recordset
    Dim crystal As CRAXDRT.Application
    Dim report As CRAXDRT.report
    Dim sSQL As String
    Dim CRXDATABASETABLE As CRAXDRT.DatabaseTable

    CRViewer.DisplayBorder = False
    CRViewer.DisplayTabs = False
    CRViewer.EnableDrillDown = False
    CRViewer.EnableRefreshButton = False

    Set conn = New ADODB.Connection
    conn.CursorLocation = adUseClient
    conn.ConnectionString = "Provider=SQLOLEDB;DATA SOURCE=dbserver;DATABASE=supply;USER ID=sa;PASSWORD=sa"
    conn.Open


    Set Rs = New ADODB.Recordset

        sSQL = ""
        sSQL = "Select * From TblSup_EnquiryH, TblJobSheet, TblSup_EnquiryD, TblSup_EnquiryE "
        sSQL = sSQL & " Where TblJobSheet.JobNumber = TblSup_EnquiryH.JobNumber "
        sSQL = sSQL & " and TblSup_EnquiryD.JobNumber = TblSup_EnquiryH.JobNumber "
        sSQL = sSQL & " and TblSup_EnquiryE.JobNumber = TblSup_EnquiryH.JobNumber "
        sSQL = sSQL & " and TblSup_EnquiryH.JobNumber = " & 12013
        sSQL = sSQL & " and TblSup_EnquiryE.PatchNo = " & "'" & "SE1" & "'"



    Rs.Open sSQL, conn, adOpenStatic, adLockReadOnly
    Set crystal = New CRAXDRT.Application 'MANAGES REPORTS
    Set report = crystal.OpenReport("C:\pALCOLATEST\PALCO\REPORT\RP TSUPPLIERENQUIRY5.RPT")
    For Each CRXDATABASETABLE In report.Database.Tables
        CRXDATABASETABLE.ConnectionProperties("USER ID") = "sa"
        CRXDATABASETABLE.ConnectionProperties("password") = "sa"
    Next CRXDATABASETABLE


    report.DiscardSavedData
    report.Database.SetDataSource Rs
    CRViewer.ReportSource = report
    CRViewer.ViewReport
    Do While CRViewer.IsBusy
        DoEvents
    Loop
    report.ExportOptions.DiskFileName = "c:\PalcoLatest\Palco\Report\supEnquiry.XLS"
    report.ExportOptions.DestinationType = crEDTDiskFile
    report.ExportOptions.FormatType = crEFTExcel50
    report.Export False
    CRViewer.Zoom 94
    Rs.Close
    Set Rs = Nothing
    conn.Close
    Set conn = Nothing
    Set crystal = Nothing
    Set report = Nothing
--- end

Note : i have created report earlier using ODBC , tHIS CODE USING OLEDB CONNECTION. SOME TIME THIS CODE GIVEN SOME NETWORK ERROR IT AFFECTED OTHER NETWORK ALSO. I NEED TO VIEW THE REPORT AND EXPORT EXCEL OR PDF USING SQLQUERY.
PLS HELP ME MY PROBLEM.
BY
CHANDRA.



Reply With Quote