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 6
Password Reminder
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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 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
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old September 7th, 2006, 08:04 AM
Registered User
Join Date: Sep 2006
Location: jakarta, jakarta, Indonesia.
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...

Reply With Quote
  #2 (permalink)  
Old September 27th, 2006, 11:52 PM
Authorized User
Join Date: Aug 2006
Location: san fernando, la union, , Philippines.
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.


Reply With Quote
  #3 (permalink)  
Old September 19th, 2007, 10:30 PM
Authorized User
Join Date: Jun 2007
Location: , , .
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.
Reply With Quote

Thread Tools Search this Thread
Search this Thread:

Advanced Search
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
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

All times are GMT -4. The time now is 02:58 AM.

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