Solved

Using Report Designer Component with Visual C++ 6.0

Posted on 2003-11-16
15
743 Views
Last Modified: 2007-12-19
Hi..

[Using: Visual C++ 6.0, MFC Dialog-Based Application, Report Designer Component, Crystal Reports 8.5]

I'm trying to develop a dialog based application that opens a report and passes the required parameters then refresh and export it to a destination folder. The application uses Report Designer Component to pass parameters to a report programatically. I referred to document "scr_rdc_cpp.pdf" from Crystal Reports Support, and came up with the following code:

// CTestApp :
IApplicationPtr gApplication;
IReportPtr gReport;

// CTestDlg :
extern CReportSchedulerApp theApp;

void CTestDlg::OnOpenReport()
{
   CFileDialog fd(TRUE, "*.rpt", NULL, OFN_EXPLORER, "Crystal Reports|*.rpt||");

   if(fd.DoModal() == IDOK)
   {
      _bstr_t bsFile = fd.GetPathName();

      theApp.gApplication.CreateInstance("CrystalDesignRuntime.Application");
      theApp.gReport = theApp.gApplication->OpenReport(bsFile);
   }
}

void CTestDlg::OnRefreshReport()
{
   UpdateData(TRUE);

   VARIANT varFrom, varTo; // the report requires two date parameters: from & to
   DATE dFrom, dTo;
   SYSTEMTIME systFrom, systTo;

   m_tFromDate.GetAsSystemTime(systFrom); // a date-time picker control
   m_tToDate.GetAsSystemTime(systTo); // a date-time picker control

   VariantInit(&varFrom);
   VariantInit(&varTo);

   SystemTimeToVariantTime(&systFrom, &dFrom);
   SystemTimeToVariantTime(&systTo, &dTo);

   varFrom.vt   = VT_DATE;
   varFrom.date = dFrom;

   varTo.vt   = VT_DATE;
   varTo.date = dTo;

   theApp.gReport->GetParameterFields()->GetItem(1)->AddCurrentValue(varFrom);
   theApp.gReport->GetParameterFields()->GetItem(2)->AddCurrentValue(varTo);
}

When I run the application, and reach the call to AddCurrentValue(), I get "Abnormal Program Termination".. I think the part that causes this problem is the last two lines in the code shown above. The very strange thing that drives me crazy is that if I replace the call to AddCurrentValue() with GetCurrentValue(), the application works fine !!! I got the impression that I can read data, put I can't change.. i.e. gReport is readonly??

I realy need to solve this problem because the thing is this application is actually a report scheduler that will be used to schedule Crystal Reports to refresh and export automatically..

PLEASE HELP...
0
Comment
Question by:abdkhlaif
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
15 Comments
 
LVL 100

Expert Comment

by:mlmcc
ID: 9758779
Instead of this line


   theApp.gReport->GetParameterFields()->GetItem(1)->AddCurrentValue

is there perhaps a

   theApp.gReport->SetParameterFields()->SetItem(1)->AddCurrentValue

I think by using the Get you are using a readonly field.

mlmcc
0
 
LVL 3

Author Comment

by:abdkhlaif
ID: 9759841
Hi..

The GetParameterFields() retreives a pointer to IParameterFieldDefinitions object that points to all the report parameters. Its like an array of IParameterFieldDefinition objects (without 's'), which in turn has a set of methods and properties to access the value of the parameter. The value of the parameter is always of type VARIANT.

In fact, the reason why I'm using this method is because its mentioned in the only document provided by Crystal Reports Support that describes using RDC with Visual C++ 6.0

Here is the document:
http://support.crystaldecisions.com/communityCS/TechnicalPapers/scr_rdc_cpp.pdf.asp?recDnlReq=Record&dnlPath=scr_rdc_cpp.pdf

I think the main problem here is that there is no enough documentation regarding this subject..

I'm running out of ideas, so any more ideas are deeply appreciated.
Thanx in advance
0
 
LVL 100

Expert Comment

by:mlmcc
ID: 9761388
Use something like

VARIANT NumberParam;
VariantInit(&NumberParam);
NumberParam.vt = VT_I2;
NumberParam.iVal = 10;
app->pReport->ParameterFields->Item[2]->AddCurrentValue(NumberParam);

You can use your code to find the correct parameter.

mlmcc
0
Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
LVL 3

Author Comment

by:abdkhlaif
ID: 9767390

I already did, take a look at my first post.
0
 
LVL 100

Expert Comment

by:mlmcc
ID: 9768812
I see where you are using the GET which is probably readonly.  Did you try it without the GET

mlmcc
0
 
LVL 3

Author Comment

by:abdkhlaif
ID: 9770603
Yes, I tried this:

theApp.gReport->ParameterFields->Item[1]->CurrentValue.date = dDate;

and I got this:

"error C2106: '=' : left operand must be l-value"

No Get's or even Set's, and still there is something wrong...


0
 
LVL 100

Expert Comment

by:mlmcc
ID: 9775527
Try it like this

app->pReport->ParameterFields->Item[2]->AddCurrentValue(dDate);

mlmcc
0
 
LVL 100

Expert Comment

by:mlmcc
ID: 9775528
Try it like this

app->pReport->ParameterFields->Item[2]->AddCurrentValue(dDate);

mlmcc
0
 
LVL 100

Expert Comment

by:mlmcc
ID: 9775559
Or better

app->pReport->ParameterFields->Item[1]->AddCurrentValue(dDate);

mlmcc
0
 
LVL 3

Author Comment

by:abdkhlaif
ID: 9777053

I already tried all the possible combinations, the same error.

0
 
LVL 13

Expert Comment

by:EwaldL
ID: 9780717
i would guess the problem is rather related to the parameter type that is passed. here is a sample of a time parameter being passed to a cr 8.5 report using the rdc in c++. i would assume that by changing the paramter VAR_TIMEVALUEONLY you could also pass a date

http://support.crystaldecisions.com/library/kbase/articles/c2010722.asp
0
 
LVL 3

Author Comment

by:abdkhlaif
ID: 9782824
Thanx for reply.

During debug, I verified that varFrom.date is valid and contains the correct date value.

I tried this method, but no change. The same annoying error.

0
 
LVL 3

Author Comment

by:abdkhlaif
ID: 9782904

This document: http://support.crystaldecisions.com/communityCS/TechnicalPapers/scr_rdc_cpp.pdf.asp?recDnlReq=Record&dnlPath=scr_rdc_cpp.pdf

says that before using RDC in my project, I should open the project's main header file and add the following line:
#import "craxdrt.dll" no_namespace

Is there a different way instead of this? is it possible that using 'import' directive could cause runtime errors?
0
 
LVL 3

Accepted Solution

by:
abdkhlaif earned 0 total points
ID: 9842621
Guys,

I figured out what was the source of the problem..

I was passing the date as {28-Nov-03 3:00:00 AM VT_DATE} but my report accepts only this: {28-Nov-03 12:00:00 AM VT_DATE} where the time is 12:00:00 AM, no more, no less (I don't know why)

Thanks for your replies.
0
 

Expert Comment

by:YensidMod
ID: 9842951
Question is PAQed and 75 points refunded.

YensidMod
Experts Exchange Moderator
0

Featured Post

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Crystal Reports: 5 Tests for Top Performance It is complete, your masterpiece report.  Not only does it meet your customer’s expectations, it blows them out the water, all they want is beautifully summarised and displayed in a myriad of ways. …
Hot fix for .Net Crystal Reports 10.2.3600.0 to fix problems with sub reports running on 64 bit operating systems ISSUE: Reports which contain subreports fail with error "Missing Parameter Value" DEPLOYMENT SERVER OS: Windows 2008 with 64 bi…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question