Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Visual Basic > VB 6 Visual Basic 6 > Pro VB 6
Pro VB 6 For advanced Visual Basic coders working in version 6 (not .NET). Beginning-level questions will be redirected to other forums, including Beginning VB 6.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Pro VB 6 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 September 7th, 2006, 08:04 AM
Registered User
Join Date: Sep 2006
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default vb connection with crystal report

dear friends,
i'm confuse to create a good code to connect vb to crsytal report.
basicly, i wanna relate a report (design in crystal report/extension .rpt) using vb code. i use OLEDB Method to connect them.

these are my codes :
Private Sub Form_Load()

Dim crxDB As CRAXDRT.Database
Dim crxReport As CRAXDRT.Report
Dim crxApp As CRAXDRT.Application

Dim strSQL As String
Dim strFormula As String
Dim strOutlet As String
Dim strStartDate As String
Dim strEndDate As String

Screen.MousePointer = vbHourglass


g_adoRst.Open strSQL, g_adoCnn, adOpenDynamic, adLockPessimistic, adCmdText

Set crxApp = New CRAXDRT.Application
Set crxReport = crxApp.OpenReport("C:\Program Files\Business Objects\Crystal Reports 11\Samples\en\Reports\TCPOS\ArticleSales.rpt", 1)
Set crxDB = crxReport.Database

crxDB.SetDataSource g_adoRst, 3, 1

CRViewer.ReportSource = crxReport


Screen.MousePointer = vbDefault

End Sub

i've got an error in this syntax
     crxDB.SetDataSource g_adoRst, 3, 1
the error from vb is : invalid TLV Records...

i have no idea about this.
thanks for helping me...

Old September 27th, 2006, 11:52 PM
Authorized User
Join Date: Aug 2006
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts

did you connect your crystal report to the database during the design phase? setup the connection to the database from the report at design time then in your vb program all you need do do is call the report.

the code would look like this:

Private Sub Show_Report()
Dim Appl As New CRAXDRT.Application
Dim Rep As New CRAXDRT.Report
Dim strFile As String

strRepFile = App.Path & "\Reports\Article Sales.rpt"
Set Rep = Appl.OpenReport(strRepFile)
CRViewer.ReportSource = Rep
Set Rep = Nothing
Set Appl = Nothing
End Sub

I hope this helps you solve the problem.


Old September 19th, 2007, 10:30 PM
Authorized User
Join Date: Jun 2007
Posts: 87
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to ivanlaw Send a message via Yahoo to ivanlaw

May I know what function for those coding below , why I should do it and is it I need to declare it first before I using those of them:

CRViewer.ReportSource = Rep

Beside that,is it use to connect with vb 6.0???
Thank you.

Similar Threads
Thread Thread Starter Forum Replies Last Post
VB 2005 Crystal Report Connection with SQL 2000 blackspear BOOK: Professional Crystal Reports for VS.NET 0 December 3rd, 2008 09:49 AM
CRYSTAL REPORT 9 Changing Connection Properties aquiintac VB Components 0 November 6th, 2007 05:17 AM
Problem in Connection Property of Crystal report 9 polravi Pro VB 6 0 February 8th, 2006 09:59 AM
Crystal Report Connection using C# in ASP .net junaidameen Crystal Reports 1 September 25th, 2005 12:11 PM
Crystal Report Database Connection winnie1778 Crystal Reports 2 October 15th, 2003 07:50 PM

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