Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Visual Basic > VB 6 Visual Basic 6 > Pro VB Databases
|
Pro VB Databases Advanced-level VB coding questions specific to using VB with databases. Beginning-level questions or issues not specific to database use will be redirected to other forums.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Pro VB Databases section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old February 3rd, 2005, 12:54 AM
Registered User
 
Join Date: Feb 2005
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.



 
Old March 29th, 2016, 03:04 AM
Registered User
 
Join Date: Mar 2016
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Public HR As New ADODB.Connection
Public Function DBConnect()


Set HR = New ADODB.Connection

HR.Open "DATABASE=" & DatabseName & ";UID=" & UserName & ";PWD=" & Password & ";DSN=" & DSNName '& "'"

End Function


Dim FromDate As Date
Dim ToDate As Date
Dim x As String

x = DateAdd("d", -1, Now)

'FromDate = Format(X, "mm-dd-yyyy")
Set DBCon = New DBManage
DBCon.DBConnect
Set recCom = New Recordset
sSql = "exec OrderT '" & Format(x, "mm-dd-yyyy") & "','" & Format(x, "mm-dd-yyyy") & "'"
DBCon.HR.Execute (sSql)
DBCon.DBDisconnect

SLR_ASupCReport.Connect = "DSN=DSNName;UID=sa;PWD=xxxx;DSQ=dbname;"


SLR_ASupCReport.ReportFileName = app.Path + "\Reports\Order Summary.rpt"

SLR_ASupCReport.DiscardSavedData = True

SLR_ASupCReport.Action = 1

SLR_ASupCReport.WindowTitle = "Order vs Invoice Analysis"
SLR_ASupCReport.ReportTitle = "Order vs Invoice Analysis"
SLR_ASupCReport.DiscardSavedData = False

' crystal report to pdf export
' CRAXDRT dll down load and register
Dim crxApplication As CRAXDRT.Application
Dim oReport As CRAXDRT.Report
Dim crxExportOptions As CRAXDRT.ExportOptions

Set crxApplication = New CRAXDRT.Application
Set oReport = crxApplication.OpenReport(app.Path + "\Reports\Order Details.rpt", 1)
oReport.Database.LogOnServer "p2sodbc.dll", "DSNNAME", "", "USERNAME", "PASSWORD"
With oReport
With .ExportOptions
.UseReportDateFormat = True
.UseReportNumberFormat = True
.FormatType = crEFTPortableDocFormat
.DestinationType = crEDTDiskFile
.DiskFileName = app.Path + "\PDF\Order Details" + Format(Now, "mm-dd-yyyy") + ".pdf"

End With
.Export False
End With





Similar Threads
Thread Thread Starter Forum Replies Last Post
how to export crystal report to excel manoj_k79 Classic ASP Basics 2 September 12th, 2011 01:52 AM
Export Crystal Report Programatically Harinder.Dhamija ASP.NET 2.0 Basics 0 July 20th, 2007 08:28 AM
Export Crystal Report to PDF aarunlal ASP.NET 2.0 Professional 1 June 28th, 2006 01:18 PM
Crystal Report export problem kalyanb BOOK: Professional Crystal Reports for VS.NET 0 December 3rd, 2004 03:00 AM
Pdf Crystal Report export Kristoff Crystal Reports 1 October 21st, 2003 09:38 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.