Click to See Complete Forum and Search --> : Crystal reports and ADO
koma
Jul 14th, 2000, 02:20 AM
I have data in an ADO-recordset in VB6 EE. I want to create a report with data from that recordset using Crystal Reports shipped with VB6 EE (version 4.6).
I can't get it right! Does Crystal Reports only support DAO?
Can I perhaps create a report file with Crystal Reports 4.6 and then use the run time library for Crystal Reports 8 that were shipped with VB?
What can I do?
fkauffman
Jul 14th, 2000, 05:27 AM
Crystal Reports version 8 will work with ADO.
(Later on in our project we will use it, so I have already checked the possibility, we will start programming the reports in a few weeks, so this is all I know about CR & VB at this moment, sorry)
good luck,
Fedor
MaBen
Jul 14th, 2000, 10:16 AM
I'm using Crystal Report 6.0 with ADO 2.5 and it's working perfectly.
I'm using the Crystal Report Designer, witch is call by the project menu in VB. In CR Designer you can set up the database connection and the SQL statement. And in VB you can force your report to use your RecordSet like this:
Form module declaration
Public myReport As New dsrmyReport
dsrmyReport is my report created by CR Designer
Sub that preview my report with my RecordSet
Dim NewPreview As New frmPreview
Dim cnnDossier As ADODB.Connection
Dim cmdDossier As ADODB.Command
Dim rsHeuresB As ADODB.Recordset
On Error GoTo ErrorHandler
Set cnnDossier = New ADODB.Connection
With cnnDossier
.CursorLocation = adUseClient
.Open "Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=Dossiers;Data Source=Serveur"
End With
Set cmdDossier = New ADODB.Command
Set rsHeuresB = New ADODB.Recordset
' Using stored procedure with parameter on SQL server 7.0
With cmdDossier
Set .ActiveConnection = cnnDossier
.CommandText = "sproc_compHeuresB_Semaine_User"
.CommandType = adCmdStoredProc
.Parameters("@Semaine") = nMySemaine
.Parameters("@Annee") = nMyAnnee
End With
'Création du Recordset
rsHeuresB.Open cmdDossier, , adOpenDynamic, adLockReadOnly
With myReport
.Database.SetDataSource rsHeuresB
.Database.Verify
NewPreview.CRViewer1.ReportSource = myReport
End With
NewPreview.CRViewer1.ViewReport
NewPreview.Show
rsHeuresB.Close
cnnDossier.Close
Set rsHeuresB = Nothing
Set cmdDossier = Nothing
Set cnnDossier = Nothing
End If
On Error GoTo 0
Exit Sub
ErrorHandler:
Select Case Err.Number
...
Have fun...
rathi
Oct 3rd, 2000, 07:41 AM
Originally posted by MaBen
I'm using Crystal Report 6.0 with ADO 2.5 and it's working perfectly.
I'm using the Crystal Report Designer, witch is call by the project menu in VB. In CR Designer you can set up the database connection and the SQL statement. And in VB you can force your report to use your RecordSet like this:
Form module declaration
Public myReport As New dsrmyReport
dsrmyReport is my report created by CR Designer
Sub that preview my report with my RecordSet
Dim NewPreview As New frmPreview
Dim cnnDossier As ADODB.Connection
Dim cmdDossier As ADODB.Command
Dim rsHeuresB As ADODB.Recordset
On Error GoTo ErrorHandler
Set cnnDossier = New ADODB.Connection
With cnnDossier
.CursorLocation = adUseClient
.Open "Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=Dossiers;Data Source=Serveur"
End With
Set cmdDossier = New ADODB.Command
Set rsHeuresB = New ADODB.Recordset
' Using stored procedure with parameter on SQL server 7.0
With cmdDossier
Set .ActiveConnection = cnnDossier
.CommandText = "sproc_compHeuresB_Semaine_User"
.CommandType = adCmdStoredProc
.Parameters("@Semaine") = nMySemaine
.Parameters("@Annee") = nMyAnnee
End With
'Création du Recordset
rsHeuresB.Open cmdDossier, , adOpenDynamic, adLockReadOnly
With myReport
.Database.SetDataSource rsHeuresB
.Database.Verify
NewPreview.CRViewer1.ReportSource = myReport
End With
NewPreview.CRViewer1.ViewReport
NewPreview.Show
rsHeuresB.Close
cnnDossier.Close
Set rsHeuresB = Nothing
Set cmdDossier = Nothing
Set cnnDossier = Nothing
End If
On Error GoTo 0
Exit Sub
ErrorHandler:
Select Case Err.Number
...
Have fun...
Hi,
Thanks for posting the above code.
To use this statement,
Public MyReport as New dsrMyreport,
What are the refereneces and components, I have to add to my
report? I use SCR 8.0 version and VB 6.0.
Thanks for your support.
sincerely,
Rathi
vbforums.com
Copyright Internet.com Inc., All Rights Reserved.