Re: Crystal 9, ActiveX Viewer & .NET

From: River Ross (river.ross_at_sbcglobal.net)
Date: 04/30/04


Date: Fri, 30 Apr 2004 17:20:34 GMT

I could not say for sure. I would be able to answer with more confidence on
a VB.NET windows app than for a web application. If you are doing a windows
app I can explain what was done however I can't explain for a web app.
However I can't give you exact source code, we used MFC you are using
VB.NET. Supposedly that is a language\IDE that of course supports use of
COM objects and ActiveX controls etc. but you will have check documentation
about how to do it.

What I did for our MFC app was the following:
1. Install CR9 (or whatever version you have) full install since you want to
be sure all the files you might need are available.

2. Create your report in CR and save it as an rpt file. Probably just start
out with a simple report just to get it into your app. If you are using a
database or some sort of open data format great it will be easier. If not
you will need to use crystal data com objects with table def .ttx files to
create a report that can get at your apps data, let's hope you don't need
this.

3. Now you need code to create a report object. In C\C++ this is done with
the #import directive and you tell it which dlls you want (you need the dlls
that house every object you need, you can either reference them by full path
or copy them into the directory of your source files):
#import "craxdrt9.dll" no_namespace
#import "Cdo32.dll" no_namespace
4. Now you can use the com objects that these dlls house. These are COM
objects and using them is largely looking at the header files they produce
when you do a build and seeing what methods are supported by them, they
support alot of stuff so you need to see what your app needs. This is a
vanilla report usage, again your code will probably have different syntax
but you will need to do the following things:
IApplicationPtr m_Application;
HRESULT hr=m_Application.CreateInstance("CrystalRuntime.Application");
  if(!SUCCEEDED(hr))
  {
   CString strMsg="Unable to create CrystalRuntime.Application instance. "
     "The most likely reason for this error is that the required Crystal
Report Runtime files "
     "are either not installed or not functional. Please consult
documentation or technical support "
     "for further details.";
   AfxMessageBox(strMsg);

   return;
  }
IReportPtr m_Report;
_bstr_t bstrReport("C:/MyDir/MyFile.rpt");//put where your app will load
file from here
 HRESULT hrRpt=m_Report = m_Application->OpenReport(bstrReport);
if(!SUCCEEDED(hr))
  {
   CString strMsg="Unable to open report.";
   AfxMessageBox(strMsg);

   return;
  }

//if you have any report params set them here etc.

//set the reports data source:
m_Report->Database->SetDataSource(...)

//various methods tell the report to print, for example:
m_Report->PrintOut(_variant_t(true));

Or you can use the ActiveX viewer to print preview it:
put the viewer as a child control on a windows form (dialog whatever), in
MFC this is done from the resource editor for the dialog and it will add
alot of the code you need and create a view class control etc, for example
CCrystalReportViewer9 m_ReportCtrl.

Then you call all the same above code except instead of printing it out you
create the window and tell the control to view it:

//in oninitdialog or some other place before it is shown
m_ReportCtrl.SetReportSource(m_pReport);
 m_ReportCtrl.ViewReport();

OK then you have to deal with your install which needs to install the CR
runtime. If you installed CR on your Dev machine of course it works but you
need your install to put the files needed on the target workstation. This
can vary based on what featueres you use, what type of db you are connecting
too, etc. You will have to consult the CR documentation, not the main help
file but the developer help files etc. Typically you need the standard
things which you can do via the merge modules and then you may have some
extra files that are needed depending on your datasource/features in your
report etc.

CR is a general tool with alot of details you will have to look into stuff
for your specific usage etc. I hope this gives you an idea of one option
for its use.

"Jeff Bray" <jJbBrRaAyY@headshoppe.ca> wrote in message
news:DOukc.32649$Np3.1183340@ursa-nb00s0.nbnet.nb.ca...
> Thank you Ross, and I should have mentioned in my post (I *always* forget
> something) is that I'm using ASP.NET/VB.NET. I am very unsure of how I
> would go about implementing what you suggest from an ASP.NET web form. I
> hate to ask to have my hand held, but can you (or anybody else) suggest
some
> specific steps for me?
>
> Thanks!
>
> Jeff
>
> "River Ross" <river.ross@sbcglobal.net> wrote in message
> news:GBtkc.4556$in4.3213@newssvr23.news.prodigy.com...
> > I got the CR9 viewer and report objects to work with an Visual C++ 6.0
MFC
> > app. This is not a .NET CR class but the general COM objects that CR9
> > supports (which may be more feature rich?). I know .NET will let you
use
> a
> > COM object but its not a prepackaged .NET easy solution.
> >
> > "Jeff Bray" <jJbBrRaAyY@headshoppe.ca> wrote in message
> > news:jXskc.32571$Np3.1180522@ursa-nb00s0.nbnet.nb.ca...
> > > Hi folks,
> > > I'm having an awfully hard time getting the ActiveX viewer to work.
Here
> > is
> > > my environment:
> > >
> > > Crystal Reports 9
> > > Crystal Enterprise Report Application Server 9
> > > Windows Server 2003
> > > Visual Studio .NET 2003
> > >
> > > Whenever I use the .NET viewer control, I can't seem to get it to
> produce
> > an
> > > ActiveX report. We need this because ALL of our reports have rotated
> > column
> > > headings and the .NET control doesn't support this and the report ends
> up
> > > looking like crap (TOTALLY unreadable)
> > >
> > > When I use the classic ASP ActiveX viewer samples, I get a host of
> > problems
> > > 1. Most of the code complains about "Session" being an undefined
> variable.
> > > It doesn't seem to recognize it as the Session object
> > > 2. I can influence the ActiveX viewer to launch, but I cannot get it
to
> > load
> > > a report
> > > 3. I'm unsure of how to pass a report name, parameters, etc to this
> > classic
> > > ActiveX ASP thing (since I can't use my codebehind stuff I suppose)
> > >
> > > In a nutshell, is there a up to date, working, .NET friendly way to
show
> a
> > > report in an ActiveX viewer? If so, how do I do it? I've COMBED the
> net
> > > for samples and other people asking the same question and there have
> only
> > > been two things that seem to happen when this question is asked:
> > > 1. Nobody replies
> > > 2. People say "check the samples Crystal came with"
> > >
> > > The samples don't work under my ASP.NET installation. Maybe it's the
new
> > > .NET version that comes with 2003, I don't know.
> > >
> > > Thanks in advance for ANY help!
> > >
> > > Jeff Bray
> > > blahblah@headshoppe.ca
> > > (replace blahblah with my jbray)
> > >
> > >
> >
> >
>
>



Relevant Pages

  • Re: Viewing TV tuner in a window
    ... *Report back, please* ... name but i dont know what i did to get that error message. ... >I recently did some maintainance on my PC (registry cleanup, windows ... > I do not have install discs, only a recovery partition (as supplied by ...
    (microsoft.public.windows.mediacenter)
  • Re: Distributing IE with .Net Windows Forms app.
    ... Well also Delphi is moving to .Net ... The Windows 98 problem should you only encounter with fresh new ... install button, as IE requires a reboot after installation ... > I should have been clearer - it's not our app that depends on IE, ...
    (microsoft.public.dotnet.framework.setup)
  • Re: Whered that go then ..?
    ... with modern OS's) some order to the drives / data etc. ... spent six years as IT manager in charge of Windows ... boot off the install CD and do a reinstall ... app will still understand them). ...
    (uk.comp.sys.mac)
  • Re: Printing a form with Laser Jet
    ... Is that an HP utility that "..is supposed to install with the printer..." ... do it from the Printer Properties menus in the Windows printers folder. ... When do you "clean" the TAG ... of the print moves, the font changes, sometimes the report, which is usually ...
    (microsoft.public.fox.vfp.reports.printing)
  • Re: FileMaker 8.5 Runtime will not start on Windows XP
    ... UST loads word perfect 's database app. ... I mostly develop for Mac so not being experienced as a Windows ... Install CD into the customers My Documents folder. ... file as opposed to the .USR file ...
    (comp.databases.filemaker)