Wednesday, March 7, 2012

How to use connectionproperties collection in c++

Crystal report 9 introduces a new feature:connectionproperties.
I find the Vb code using it

Dim Report As CRAXDRT.Report
' Open the report from a file
Set Report = Application.OpenReport("C:\Mytest.rpt")

' Provide database logon credentials (in this case
' for an OLEDB connection to a SQL Server database)
Dim tbl As CRAXDRT.DatabaseTable
Set tbl = Report.Database.Tables(1)
tbl.ConnectionProperties.Item("password")="mypass"
...

This works well in vb.But in Vc++,I can't find the collection.I add type library in stdafx.h
#import "craxdrt9.dll" no_namespace
...
IApplicationPtr pApplication;
pApplication.CreateInstance("CrystalRuntime.Application.9");
IReportPtr pReport;
pReport = pApplication->OpenReport("c:\mytest.rpt");
IDatabasePtr pDb;
pDb = pReport->Database;
IDatabaseTablePtr pDbTable;
pDbTable = pDb->Tables->GetItem(1);

I think I should reference connectionproperties collection through either pDb(Database object,as file "crystal report developers help.chm", chapter "Report Designer Component Object Model" showes) or pDbTable(DatabaseTable object,as Vb example showes).But I can't find the collection.

Does that mean the collection is only supported in vb.If not so,how to use.It's better give an example.
:confused:I'm sorry, I know nothing about VC++, but I've found some VB examples of code on Crystal's Website:

http://support.businessobjects.com/search/advsearch.asp

If you look there, you might be able to find some VC++ references. You could also try an internet search engine such as www.google.com.

Good luck and sorry I couldn't be of any more help.

No comments:

Post a Comment