problem with Crystal Report and ADO command object [RESOLVED]
Hello;
I have been asked to modify an application as such:
At present, each time the data is accessed, it is done with recordsets only (ie. recset.Open sql....etc). In order to improve performance on our Oracle database, I am changing all the queries and replacing the record sets with parameterized command objects. The following code is the way it was before I changed it:
VB Code:
Set rsQuery = New ADODB.Recordset
rsQuery.Open ("SELECT a.garage_id, TO_NUMBER(SUBSTR(a.workorder_no,21,10)) workorder_no, a.lessee, a.license, a.status, a.opendate, a.closedate, a.down_open, a.down_close, a.problem, a.total, a.credit, a.collator, a.vin, a.radio, a.vehicle_year, a.make, a.model, a.wo_odometer, a.odometer, a.unit_no, a.vehicle_no, a.suffix, lessee_data_a, a.credit_expiry, b.address1 FROM work_order a, garage_view b WHERE a.garage_id = b.garage_id AND a.workorder_no = '" & selectedWorkorder & "'"), DBConnection
mainReport.Database.SetDataSource rsQuery
...
The above is a snippet from a block that prints a Crystal Report, and when the code is as above, it prints just fine. Here is the modififed code:
VB Code:
sql = "SELECT a.garage_id, TO_NUMBER(SUBSTR(a.workorder_no,21,10)) workorder_no, a.lessee, " _
& "a.license, a.status, a.opendate, a.closedate, a.down_open, a.down_close, a.problem, " _
& "a.total, a.credit, a.collator, a.vin, a.radio, a.vehicle_year, a.make, a.model, " _
& "a.wo_odometer, a.odometer, a.unit_no, a.vehicle_no, a.suffix, lessee_data_a, " _
& "a.credit_expiry, b.address1 FROM work_order a, garage_view b WHERE a.garage_id = " _
& "b.garage_id AND a.workorder_no=?"
Dim testCommand As New ADODB.Command
Dim testPara As New ADODB.Parameter
testCommand.ActiveConnection = DBConnection
testCommand.CommandType = adCmdText
Set testPara = testCommand.CreateParameter("workorder_no", adVarChar, adParamInput, 50, selectedWorkorder)
testCommand.Parameters.Append testPara
testCommand.CommandText = sql
Set rsQuery = testCommand.Execute
mainReport.Database.SetDataSource rsQuery
....
With the above code, no error is raised whatsoever....the dialog for number of copies to print pops up, the print icon then appears in my system tray briefly after I click OK, AND NOTHING COMES OUT OF THE PRINTER!!
Being new to Crystal Reports, I am wondering if I should know something about using a paramterized command object to open the record set rather than using the recordset.Open method, or perhaps something else I am missing! Any thoughts would be much appreciated