Quantcast
Channel: SCN : Unanswered Discussions - SAP Crystal Reports, version for Visual Studio
Viewing all articles
Browse latest Browse all 2556

crystal report subreport connect DB Problem

$
0
0

I have rpt file was set the connect DB(AAAA). This file have two reproject (main report and subreport)

The subreport parameter is linked to main report.

These two report will get the data from DB by the parameter.

Server Name:AAAA, Database Name: AAAA, UserID: AAAA, Password:AAAA

for testing and save it.

 

I am trying to build a MFC project with crystal report 13

My project call this rpt file and pass a parameter to main

The crystal report main report and subreport can get correct infomation where connect to the DB(AAAA)

but when I connect to the other DB.

My project only the crystal report main report can get the correct infomation, the subreport cannot get correct infomation.

it show a diolog to ask me "enter the parameter".After passing a corrent parameter, the result also not corrent.

 

The program code:

CrystalDecisions::Windows::Forms::CrystalReportViewer^  crystalReportViewer1;

ReportDocument boReportDocument = gcnew ReportDocument();

boReportDocument->Load(strFilePath);

String^ strUser = gcnew String (ReportPara->strUser);

String^ strPassword = gcnew String (ReportPara->strPassword);

String^ strServer = gcnew String (ReportPara->strServer);

String^ strDatabase = gcnew String (ReportPara->strDatabase);

boReportDocument->DataSourceConnections[0]->SetConnection(strServer,strDatabase,strUser,strPassword);

ParameterValues^ pv = gcnew ParameterValues();

ParameterDiscreteValue^ pdv = gcnew ParameterDiscreteValue();

pdv->Value =ReportPara->varDate;

pv->Add(pdv);

boReportDocument->DataDefinition->ParameterFields[0]->ApplyCurrentValues(pv);

crystalReportViewer1->ReportSource = boReportDocument;

 

I have try to change the subreport DataSourceConnections:

for (int j; j <boReportDocument->DataSourceConnections->Count;j++)

      boReportDocument->Subreports[0]->DataSourceConnections[j]->SetConnection(strServer,strDatabase,strUser,strPassword);

but the result is also not corrent

 

I have try to pass parameter to the subreport:
pv->Add(pdv);
boReportDocument->DataDefinition->ParameterFields[1]->ApplyCurrentValues(pv);

for (int i; i <boReportDocument->DataDefinition->ParameterFields->Count;i++)

{

     pdv->Value =ReportPara->varDate;

     pv->Add(pdv)

     boReportDocument->Subreports[0]->DataDefinition->ParameterFields[0]->ApplyCurrentValues(pv);

}

but the result is also not corrent

 

I have try to set the ReportViewer LogOnInfo

TableLogOnInfo^ loi;
loi = boReportDocument->Database->Tables[0]->LogOnInfo;
oTblLogOnInfos->Add(loi);
for (int j=0; j<boReportDocument->Subreports[0]->Database->Tables->Count;j++)
{
      loi = boReportDocument->Subreports[0]->Database->Tables[j]->LogOnInfo;
      oTblLogOnInfos->Add(loi);
}

crystalReportViewer1->LogOnInfo = oTblLogOnInfos;

but the result is also not corrent


Viewing all articles
Browse latest Browse all 2556

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>