Click to See Complete Forum and Search --> : CR 4.6.1 / VB / MySql - Newb needs help


jayceecee
September 6th, 2006, 05:44 PM
Hi All,

I have started using the Crystal Reports Designer V 4.6.1
this week to create reports using data pulled from a MySql
database using VB6.

I can create the report in the designer.
I get it to print using CrystalReport1.PrintReport in VB .
But it uses the data that it used when created even though the "Save Data with Report" option is not checked and the option CrystalReport.DiscardSavedData = true.

I guess that the database needs to be requeried at runtime to ensure data
correctness so I retrieved the recordset by using the same sql query
the report generator used. This recordset now has the updated information from MySql.

My "long winded" question is ,How do I "pass" this recordset to the report
to ensure the data is current each time the report is generated.

Any help with code example would be greatly appreciated,

Jay

Heres what I have so far,

Private Sub cmdTestCrystal_Click()
CrySqlStr = "" 'reset sql variable to hold new sql query
CrySqlStr = GetCrystalSqlString(0) 'using a case statement to retrieve
'different Sql queries

'Connect to MySql Database
CrystalReport1.Connect = connectMysql("root", passwd, gblIpAddress, gblDBPasswd, conn, rs)


rs.Open CrySqlStr, conn 'open the database and retrieve recordset

CrystalReport1.ReportFileName = App.Path "Reports\Payments.rpt")
CrystalReport1.DiscardSavedData = True 'Clears report so we work
' from recordset


' Here's the problem - I think !!!
'************************************************************
CrystalReport1.DataSource = rs 'Now link the report to the recordset
'************************************************************

CrystalReport1.PrintReport 'Print the report

'The recordset rs is populated with the correct data based on the sql query , tested here
MsgBox ("rs.Fields(1) = ") + rs.Fields(1)

End Sub