Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

TTX & Recordset Problem (CR 9.0)

Status
Not open for further replies.

krishna

Programmer
Mar 30, 2000
121
IN
Hi

I am using Crystal Ver 9.0. I want to build a no of reports using recordset. What is the best way to do this. I serached this forum and found an anser that there are 2 ways to do this

1) Using ttx file
2) Using Active data driver.

I created a sample report using ttx file. I am using a sql server stored procedure to populate the recordset. I am having a strange problem. If I use a parameterised stored procedure, the report will not show any data. I checked the recordset. The recordset contains all the data I want.
If I remove this parameter from the stored procedure, the report will show all the data. Why this strange behaviour?

2) How I can use the recordset using Active data driver? Could somebody explain to me the the detailed steps?

Thanks in advance...

Regards
Krishna Kumar
 
Hi Krisha kumar,

You can base your datasource to be ADO recordset. You will just have to create the .rpt file to use the ADO driver(Crdb_ado.dll).
Execute the stored procedure and send the recordset to CR, this is more reliable than passing the stored procedure to CR, because CR has to execute the SP and get the data back. Whereas when you send the recordset to CR, it has the data and just has to manipulate it.

What you have to do is Open the Report and then set the datasource of the table object to the ado recordset.


oReport = OApplication.OpenReport
Oreport.Database.Tables.Item(1).DataSource = adoRecordset.

Hope this helps. If you want elaborate code in VC++ let me know.

Cheers,
Techi
 
Hi Techi.

Thank you for your mail.

I am populating the recorset from a VB application. After that I am setting the datasource. The fuuny thing is that if I remove the parameters, the report works fine. Otherwise the report will be blank.. Is there anything I have to set on recordset. I am using forward only recordset..

Regards
Krishna Kumar
 
Here is the code I tried...

Dim objRptOptions As ExportOptions
Dim objCrysApp As New CRAXDRT.Application
Dim objCrysRep As Report


Dim adoCon As New ADODB.Connection
Dim adoCom As New ADODB.Command
Dim adoRec As ADODB.Recordset

adoCon.ConnectionString = "Provider=SQLOLEDB.1;Persist Security Info=False;User ID=sa;Initial Catalog=AAMI_PARL_OCT_14_2002;Data Source=A02"
adoCon.Open

Set adoCom.ActiveConnection = adoCon
adoCom.CommandText = "KKTESTASSETCLASS"
adoCom.CommandType = adCmdStoredProc
adoCom.Parameters(1).Value = 20

Set adoRec = New ADODB.Recordset
With adoRec
.CursorType = adOpenKeyset
.LockType = adLockBatchOptimistic
End With
Set adoRec = adoCom.Execute() '

If adoRec.EOF Then MsgBox "No Data": Exit Sub

objCrysRep.Database.Tables(1).SetDataSource adoRec

Set objRptOptions = objCrysRep.ExportOptions
With objRptOptions
.DestinationType = 1
.FormatType = &H1F '&H20
.DiskFileName = strPDFStore & "\" & strPDFFile
End With
objCrysRep.DisplayProgressDialog = False

objCrysRep.Export False

Regards
Krishna Kumar
 
Hi All..

I set the cursorlocation to the client and it worked. But why this behaviour? I have searched many sites and havent came across such an issue. Could any body explain this?

Regards
Krishna Kumar
 
Hi Krishna,

Yes CR requires a Clientside cursor. I found this out while working on my appn. There is no documentation in CR help regarding this.

just look at the following thread
thread766-403227
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top