on 04-22-2009 12:22 PM
Dear All,
I am using Crystal report X1 for report generation.Now I am setting the database location manually in the crystal report. How can I Set the database location from the Source code.
Awaiting for your reply.
Thanks in advance.
Regards,
Rahaneef T
What Crystal Reports SDK are you planning to use? Have you looked at any developer help files? Have you searched the forums? Have you searched the [articles database|https://www.sdn.sap.com/irj/sdn/businessobjects-articles]? Have you searched the [notes|https://www.sdn.sap.com/irj/scn/advancedsearch?cat=sdn_ossnotes&query=&adv=true]
database? Have you looked at any [sample apps|https://www.sdn.sap.com/irj/scn/advancedsearch?cat=sdn_ossnotes&query=&adv=true¬e_number=&component=&sdn_updated_on_comparator=ge&sdn_updated_on=]? Just a few good suggestions...
Ludek
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Dear Ludek,
I am using Crystal report XI R2 RDC with vc++. I have gone through the samples and references suggested by you. I tried to use IDatabase::SetDataSource function to set the database location. But it shows some error. Could you please suggest me how to use the SetDataSource() or some other way to set the database location.
Thank you,
Regards,
Rahaneef
You want to use the connection properties bag. SetDatasource is for ADO recordsets only. Unfortunately, most of the resources will be in VB. Before I do give you some resources, I should let you know that the RDC has been retired in CR 2008. Not sure, but htis may have some bearing on your project, depending on life cycle considerations. This blog has more info:
/people/ludek.uher/blog/2008/10/20/report-designer-component--past-present-future
If you decide to go on with the RDC, the best place to start as far as database connections will be with this article:
As a general help for C++ this article may help:
I'm also attaching a sample C++ app that uses the connection properties bag (it uses CR 9, so if you want to run it, you'll have to update the references, or just copy and paste the pertinent code into your project.
Occasionally the uploads don't work, so if you have issues with the download, let me know and I'll email the app to you.
Ludek
Dear Ludek,
I have gone through the attached code. But from that also am not getting clear idea about the GetConnectionProperties() function. I have tried to use SetTableLocation() which available in IDatabaseTablePtr , but it was also not working. What is your opinion about this.
Is anybody used some other way to set location of the database dynamically.
Awaiting for your replies.
Regards,
Rahaneef
My C++ knowledge is close to null, so all I could do is provide the samples. Perhaps somebody else can jump in. Other than that, you may consider obtaining a support case and talk to a support rep, see if they can help out. Phone support can be obtained here;
Ludek
Here's a routine that also searches for subreports to set the log on info. Simply remove that aprt to set the main report logon info:
IDatabaseTablePtr pTable;
//get first table
pTable = m_Report->Database->Tables->GetItem(1) ;
long lTableCount = m_Report->Database->Tables->Count;
for( long lTable=1; lTable<=lTableCount; lTable++ )
{
pTable = m_Report->Database->Tables->GetItem(lTable);
pTable->ConnectionProperties->DeleteAll();
pTable->ConnectionProperties->Add("DSN", "Name of your DSN");
pTable->ConnectionProperties->Add("Database", "Demo");
pTable->ConnectionProperties->Add("Password", "sa");
pTable->ConnectionProperties->Add("User ID", "1Oem2000");
}
// Log on the tables of the subreports.
long lSectionCount = m_Report->Sections->Count;
for( long lSection=1; lSection<=lSectionCount; lSection++ )
{
ISectionPtr pSection = m_Report->Sections->Item[lSection];
long lSubreportCount = pSection->ReportObjects->Count;
for( long lSubreport=1; lSubreport<=lSubreportCount; lSubreport++ )
{
IReportObjectPtr pSubreportObject = pSection->ReportObjects->Item[lSubreport];
CRObjectKind crObjectKind;
pSubreportObject->get_Kind(&crObjectKind);
if( crObjectKind == crSubreportObject )
{
ISubreportObjectPtr SubReportPtr = pSubreportObject;
IReportPtr pSubReport = SubReportPtr->OpenSubreport();
long lTableCount = pSubReport->Database->Tables->Count;
for( long lTable=1; lTable<=lTableCount; lTable++ )
{
pTable = m_Report->Database->Tables->GetItem(lTable);
pTable->ConnectionProperties->DeleteAll();
//pTable->ConnectionProperties->Add("DSN", "dwcb12003");
pTable->ConnectionProperties->Add("Database", "CrystalEport_DB");
pTable->ConnectionProperties->Add("Password", "sa");
pTable->ConnectionProperties->Add("User ID", "1Oem2000");
}
}
}
}
If that doesn't work you need to tell us what is the error you are getting and paste in the code you are using.
User | Count |
---|---|
90 | |
10 | |
10 | |
10 | |
7 | |
7 | |
6 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.