cancel
Showing results for 
Search instead for 
Did you mean: 

How to set database location in the crystal report X1 from the Source code.

Former Member
0 Kudos

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

Accepted Solutions (1)

Accepted Solutions (1)

former_member183750
Active Contributor
0 Kudos

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&note_number=&component=&sdn_updated_on_comparator=ge&sdn_updated_on=]? Just a few good suggestions...

Ludek

Former Member
0 Kudos

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

former_member183750
Active Contributor
0 Kudos

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:

https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/00635998-751e-2b10-9cba-f50ee1e4...

As a general help for C++ this article may help:

https://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/d07d2ec2-721e-2b10-73ba-d0f237f6...

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

Former Member
0 Kudos

Dear Ludek,

I can't download the attachement sent by you. Could you please resend it so that I can download and use it.

Regards,

Rahaneef

former_member183750
Active Contributor
0 Kudos

Yup. I'll send it to you

Ludek

Former Member
0 Kudos

I didn't receive the attachment . Please resend it.

Former Member
0 Kudos

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

former_member183750
Active Contributor
0 Kudos

You've got to figure out the connectionProperties bag. No other methods or properties will work for you - they are only there for backward compatibility and using them is just not a good idea.

Ludek

Former Member
0 Kudos

Dear All,

I have searched and tried some vb samples of Connectionproperties. But all are not fulfilling my requirement Please help me with some connectionproperties C++ samples using ODBC and ADO DB connectivity.

Regards,

Rahaneef

Edited by: rahaneef t on Apr 29, 2009 2:30 PM

former_member183750
Active Contributor
0 Kudos

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;

http://store.businessobjects.com/store/bobjamer/DisplayProductByTypePage&parentCategoryID=&categoryI...

Ludek

0 Kudos

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.

Former Member
0 Kudos

Dear All,

thank you all for your timely support.

It works fine when I follow the steps suggested by you..

Thanks and regards,

Rahaneef t

Answers (0)