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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Using Database.Tables.Add() method with ADO in VB6

Status
Not open for further replies.

trentl

Programmer
May 20, 2005
2
US
While evaluating Crystal XI (attempting to upgrade from 8.5), I've run into this problem:

In a VB6 thick-client environment, I have a dynamically-built ADO recordset object that does NOT employ an ADO Connection or ADO Command object.

What I want to do is create a new (blank) report at runtime and add this ADO recordset object to the report's databasetables collection.

The reason I want to do this is because the XI documentation claims that the p2smon.dll (active data) data driver has been deprecated, along with the CreateFieldDefFile() and CreateReportOnRuntimeDS() functions, which worked fairly well in previous versions of our application.

So I'm basically looking for a new way to create a new report and add a recordset (or multiple recordsets!) to it at runtime. I thought the Add method of the DatabaseTables collection would do the trick, but I can't get it to work and documentation is sparse. Here's some VB6 code:

Code:
Dim adoTemp As ADODB.Recordset
Dim crxApp  As CRAXDDRT.Application
Dim crxRpt  As CRAXDDRT.Report

' adoTemp has been already filled with data at this point. 
Set crxApp = New CRAXDDRT.Application
Set crxRpt = crxApp.NewReport
crxRpt.Database.Tables.Add "", , adoTemp
The above causes error "-2147189139 Invalid Argument provided."

I've tried other permutations of the above code, including specifying database dll's, with no luck. Any suggestions?

Thanks,
Trent
 
Luckily, and through almost endless trial-and-error, I found the solution on my own. The correct syntax for the situation is:

Code:
crxRPT.Database.Tables.Add strTTXFile, , , , "crdb_fielddef.dll"
...where strTTXFile is the full path and file name of the Field Definition (.ttx) file.

Then, of course, the SetDataSource method is used later to pass the ADO recordset object to the report object for viewing.

Hopefully this will save others the same headache I've had for the past two days.

Trent
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top