Solved

Using Report Designer Component with Visual C++ 6.0

Posted on 2003-11-16
15
741 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
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: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

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

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

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

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…
Hello everyone, Hope you find this as helpful as we did. We have on the company I work for an application built in Delphi V with Crystal Reports 8. We all know that Crystal & Delphi can be temperamental sometimes and the worst thing is, nearly…
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

829 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