Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Help!! Crystal Report XI with VFP9 4

Status
Not open for further replies.

endhey

Programmer
Jan 27, 2012
9
I got a problem to open report(CR XI) from VFP9,,when I using CR 8.5 there is no problem,,
below is coding for open report CR8.5 (there is no problem):
oCRApp = createobject("CrystalRuntime.Application")
oRep = oCRApp.OpenReport("D:\SIAP2\CR\Supplier.rpt")
oRep.Preview
thisform.olecontrol1.ReportSource= oRep
thisform.olecontrol1.viewReport()
thisform.olecontrol1.zoom (100)

Coding for open Report CR XI:
oCRApp = createobject("CrystalReports11.ObjectFactory.1")
oRep = oCRApp.OpenReport("D:\SIAP2\CR\Supplier.rpt") &&error
oRep.Preview
thisform.olecontrol1.ReportSource= oRep
thisform.olecontrol1.viewReport()
thisform.olecontrol1.zoom (100)

the error is "OLE Error code 0x80020006: Unknown name" and error pointing to oRep = oCRApp.OpenReport("D:\SIAP2\CR\Supplier.rpt")

Any help would be appreciated.


 
obviously one thing has changed:

CrystalRuntime.Application -> CrystalReports11.ObjectFactory.1

And you seem to think this is all that changes. But is it?
What you're missing is compatibility. Maybe there is a way to get the compatible Application object from the ObjectFactory object, but surely the name ObjectFactory already suggests this is not the same as the Application object was for Crystal 8.5

Is there no documentation about Crystal XI automation?

Bye, Olaf.
 
Hello Endhey, and welcome to the forum.

I don't have the CR XI Help file to hand, but as far as I know, your 8.5 code should work exactly the same in XI. I don't know why you are trying to instantiate "CrystalReports11.ObjectFactory.1". You should be able to work with "CrystalRuntime.Application", just as before.

That said, one thing you can do to help solve the problem is to run the code in the command window, and use Intellisense to check the method names. So, first run your CREATEOBJECT() in the command window. Then type oCRApp followed by a dot. Intellisense will show you all the methods (and properties) available for the object. Scroll down to a particular method, and you will see the parameters that it requires.

But I suggest you start by using your original CREATEOBJECT() call, just as you did in 8.5.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips, training, consultancy
 
Dear OlafDoschke and MikeLewis,

Thanks for your answer,,

Olaf : i've no documentation about Crystal XI automation,,where can I found it..?

MikeLewis :If I work with "CrystalRuntime.Application" on CR XI, the error is "Class Definition CrystalRuntime.Application is not found".. I've been using Intellisense,,there is no problem when I type oCRApp followed by a dot,the method OpenReport is show,,
I don't know what to do..
Is Crysttal Report XI only Support in Windows 7..? because I'm using windows Xp Pro SP3.
 
Endhey,

If you can see OpenReport in Intellisense, it's surprising it is giving you an "Unknown name" error. The only thing I can think of is that the parameters have changed, but I can't see why they should have. Can you see an indication of the parameters in Intellisense?

Crystal Reports XI is certainly supported in XP. It pre-dates Windows 7 by a wide margin.

If you look on the Crystal CD, you should find a developers Help file. In earlier versions, it was called CrystalDevHelp.chm, and was located under Developer Files/Help. As I said, I don't have CR XI on my current system, so I don't know if that still applies, but the file should be there somewhere.

Mike


__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips, training, consultancy
 
Craig has an important point there, most probably.

endhey said> i've no documentation about Crystal XI automation,,where can I found it..?

I was asking, if there is no documentation. Could be. If you have R1 only, that would explain it, including Craigs info there is no COM interface for that version.

Also you may not get docs on COM classes anyway, even if there is such an interface, as that is not the user interface of Crystal. But normally you can get developer documentation, if you ask a vendor. Why should they do a COM interface and then not let you use it?

From what I found out there are mainly two developer interfaces: RAS and RDK. The objectfactory belongs to RAS, which is meant to be used remotely, eg in conjunction with SQL Server at that same server. It can also be installed and used local, though. No matter how, it's a totally different approach to program it.

With your old COM code you're better off with a local install of the Crystal Report version Craig mentions, including COM classes to automate it as you are used to.

Bye, Olaf.
 
I must say I'm surprised that the first release of XI didn't support COM, given that all earlier versions (going back to CR 8.0) did support it. But I don't doubt Craig's advice, given that he knows more about it than I do.

Also, all the earlier versions did include documentation for the COM classes. This was the developer Help file that I mentioned earlier. As far as I recall, it wasn't installed automatically; you had to manually copy it from the CD.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips, training, consultancy
 
Can I just say I applaud using the variable name oCrapp? That has been my usual reaction when working with CR in the past. <g>
 
@Dan: Historically, there are two COM interfaces to CR. One called crystalruntime.application and the other called CRAPI, pronounced "crappy". Guess which one you should not used.

Craig Berntson
MCSD, Visual C# MVP,
 
@Dan: Haha, I didn't even spot that.
@Craig: The answer is crystal clear.

@endhey: Don't let that discourage you to use Crystal Reports. It is an often used reporting engine, of course. And despite you could also use VFP reports or SQL Server Reporting Services, you will want to keep your CR code, for sure.

Bye, Olaf.
 
Dear All,,
@mike : I'm Confused too,why it could be "Unknown name" error
@Dan : I put the coding and variable name on the web,,maybe it's yours..
@Craig : I think,I'll try using Crystal XI R2,,
@OlafDoschke: I'll keep trying to learn about Crystal Report,, I'm newbie using Crystal report..

Thanks a lot and I appreciated for all of your answer and advice,,

regards,

Lucky Endey
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top