|
-
Mar 17th, 2003, 12:34 PM
#1
Thread Starter
Hyperactive Member
Passing ADO to CR9 during Runtime [INFO]
After trying to workout how to pass my recordset to a Report created by CR9 since last Friday, I decided to call for TECHSUP with Crystal Decisions.
CR9 rocks IMHO!!. Now, you don't need a TTX file or OCX to pass your recordset!!!
Here are the things you need to setup:
(1) As Project Reference, you need to select:
- Crystal Report 9 ActiveX Designer Runtime Library
- Microsoft ActiveX Data Object 2.x Library
(2) As Project Component, you need to select:
- Crystal Report Viewer Control 9
(3) Create a Report outside VB environment (not RDC) and saved the file (file extention = .RPT).
- Remember, when saving the report, unclick the "SAVE DATA WITH REPORT" option on the file menu.
I don't know if this matters but I use:
-VB6 Developer Edition
-CR9 Developer Edition (ver. 9.2.0.448)
-MDAC 2.6
Here's the sample CODE:
Option Explicit
Dim crAPPLICATION As CRAXDRT.Application
Dim crREPORT As CRAXDRT.Report
Dim adoCN As New ADODB.Connection
Dim ADOrs As New ADODB.Recordset
Private Sub Form_Load()
Dim CNSTR As String
CNSTR = "Provider=MSDASQL.1;Persist Security Info=False;Extended Properties="""
CNSTR = CNSTR & "DSN=MQIS;Description=SQL Server;UID=APRINCIP;APP=Visual Basic;WSID=ALAINP;DATABASE=LMS"""
Set adoCN = New ADODB.Connection
Set ADOrs = New ADODB.Recordset
Set crAPPLICATION = New CRAXDRT.Application
Set crREPORT = crAPPLICATION.OpenReport("C:\REPORTS\REPORT1.RPT")
With adoCN
.ConnectionString = CNSTR
.CursorLocation = adUseClient
.Open
End With
With ADOrs
.ActiveConnection = adoCN
.CursorType = adOpenDynamic
.Open "SELECT * FROM ACCOUNT WHERE ACCOUNTID < 10"
End With
crREPORT.Database.SetDataSource ADOrs, 3, 1
CRViewer91.ReportSource = crREPORT
CRViewer91.ViewReport
End Sub
Private Sub Form_Resize()
With CRViewer91
.Top = 0
.Left = 0
.Width = Me.ScaleWidth
.Height = Me.ScaleHeight
End With
End Sub
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|