Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Visual Basic > VB 6 Visual Basic 6 > Pro VB Databases
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developersí questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Display Modes
  #1 (permalink)  
Old February 2nd, 2005, 11:54 PM
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
  #2 (permalink)  
Old March 29th, 2016, 03:04 AM
Registered User
Points: 3, Level: 1
Points: 3, Level: 1 Points: 3, Level: 1 Points: 3, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
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
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

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 02:00 AM
Pdf Crystal Report export Kristoff Crystal Reports 1 October 21st, 2003 09:38 AM



All times are GMT -4. The time now is 12:22 AM.


Powered by vBulletin®
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.