cancel
Showing results for 
Search instead for 
Did you mean: 

VB6 & XML Datasource using Native XML Driver

Former Member
0 Kudos

We used to use reports that used ADO XML dataset, and in VB 6 we easily told the report which XML file to use by:

Dim objCRReport As CRAXDRT.Report

Set objCRReport = objCRApplication.OpenReport(App.path & "\crystal\" + rptName)

objCRReport.DiscardSavedData

objCRReport.Database.Tables.Item(1).Location = xmlFile

where xmlFile was the fully qualified path to the xml data to pass to the report.

Now we are trying to do this with a new report which uses a XML Native driver as its connection method. In VB6, how can we pass different xml files to use?

We looked at objCRReport.Database.SetDataSource, but it expects some parameters that I don't understand ( data , { data type } , { table number } )

Is there an example anywhere of how to switch your datasource in code while using the XML Native Driver?

Accepted Solutions (1)

Accepted Solutions (1)

former_member183750
Active Contributor
0 Kudos

See [this|https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.km.cm.docs/oss_notes/sdn_oss_boj_erq/sap(bD1lbiZjPTAwMQ==)/bc/bsp/spn/scn_bosap/notes.do] note.

I would also recommend that you read the following regarding distribution of the runtime. This is important as the xml driver (crdb_xml.dll) uses Java:

Apart from the regular deployment procedure for COM/RDC/NET applications, you have to follow the additional below-given steps in the client machines.

Install the Java (JVM) 2 Runtime Environment (this is essentially the Java Framework needed to launch the crdb_xml native driver 1.4.2 from the java sun web site at:

http://java.sun.com/j2se/1.4.2/download.html.

Create a java folder inside the " C:Program FilesBusiness ObjectsCommon3.0";.

Copy over the Crconfig.xml(C:Program FilesCommon FilesBusiness Objects3.0java) file from the development machine to the deployed machine in at the following path "C:Program FilesCommon FilesBusiness Objects3.0java" path. Open the crconfig.xml ; this file in Notepad and search for the line <JavaDir>. If JRE is installed to C:Program FilesJavaj2re1.4.2_12in then the value should be look like this <JavaDir> C:Program FilesJavaj2re1.4.2_12in</JavaDir>.

Create a folder called lib in the "C:Program FilesCommon FilesBusiness Objects3.0java".

Copy over the entire contents of the lib folder (especially the external folder) from the development machine to the newly created lib machine on the deployed machine. The point of this is to ensure that the crconfig.xml file contains all the files here which exist at the correct path which they now should because we copied over the lib and external directories.

Copy crdb_xml.dll, crdb_xml_res_en, and all the files with "crdb_xml_res_xx from your development machine to the deployment machine (C:Program FilesCommon FilesBusiness Objects3.0in).

Restart your machine and try accessing your web application. The reports will show up the data without any issue.

The above is written for CR XI release 1. You may have to adjust the path given above as you do not specify the version of Crystal reports you are using.

Ludek

Former Member
0 Kudos

Interesting info, thanks. The link you posted for the SAP note, it says Changing the XML database at runtime using the RDC

I'm not 100% sure what "using the RDC" means, but is that what I'm doing already? I'm using the COM objects in VB6 (not asp & vb script).

Edit: I'm using CR XI r2

Edited by: Kurtas BB on Sep 22, 2008 3:55 PM

former_member183750
Active Contributor
0 Kudos

Yes, you are correct. RDC (report designer component) is a COM technology. The actual engine is the craxdrt.dll and it uses the crviewer.dll to display the reports. All of these are used quite interchangeably, and as you found out confusingly...

Ludek

Former Member
0 Kudos

Ludek,

I've sent this info to my co-worker who actually is doing that coding, I thought he had tried the code you linked already but was getting an error. If so I will post the error he got.

I am interested where you got the Java information, if there was a white paper for that procedure? Not that I distrust your information, but a document for us to have on file would be excellent.

Thanks.

former_member183750
Active Contributor
0 Kudos

It is in a "kbase" now with SAP called "note" that I wrote. Unfortunately, it's marked as Internal. No idea why (I'll look into it), but the solution does work. I've used it with a number of customers.

Meanwhile, I'll keep my fingers crossed on the code...

Ludek

Former Member
0 Kudos

I have the error we are getting when using the code for native driver, VB debugger shows that the program crashes on this line from the code:

CRViewer1.ViewReport

With this error:

Failed to load database information

With no changes to the VB code, we can load ADO.NET XML reports. The reports we create with Native XML driver load in Crystal XI and are able to be previewed, so we assume the XML / XSD relation is ok with Crystal. Any ideas?

former_member183750
Active Contributor
0 Kudos

What version of Crystal Reports are you using?

Have you ever downloaded any updates for that version of Crystal reports?

Confirm that the rep[rot works in the VB app if you do not try to change the xml / xsd path?

Send me the full code as used to view the report. E.g; from load to view.

Ludek

Former Member
0 Kudos

We commented out the line that switches the XML source, and got the same error.

Friday we discovered our reports were being developed with CR XI R2, but the application was distributing CR XI Release dlls, we didn't think this was a big deal. Your post led us to update the application to lauch the correct viewer version.

Now that our app's viewer matches our development version, we were able to launch the report with the lines still commented out that switch the source.

We then uncommented the lines that switch the source of the XML, and are getting this error: Logon Failed. So we can launch the 'base report' that the .RPT was built from, but can not switch xml sources. We are getting the logon failed error on the same line that I mentioned above, at CRViewer.ViewReport.

As far as the versioning, I'm not sure what service pack of CR XI R2 we are running between the two of us, but I'm downloading all four of them right now. This will take several hours.

former_member183750
Active Contributor
0 Kudos

I think we're on the right track.

First, you will have to settle on which version of CR you want to use. CR XI r1 or CR XI r2. And yes, it is a big deal. Essentially, the two are very different versions of Crystal Reports.

Assuming you want to move on to CR XI r2, I would strongly recommend the following

1) Uninstall CR XI r1 (if it is still on the computer).

2) Reinstall CR XI r2.

3) Download the latest Service pack from here;

https://smpdl.sap-ag.de/~sapidp/012002523100006255422008E/crxir2_sp4_inc.exe

4) Remove any CR XI r1 references from your VB 6 project (you may have to delete the viewer from the form, before VB will let you remove the reference to the viewer)

5) Re-add references to the craxdrt.dll and crviewer.dll of version 11.5

6) Recompile the app and see how it works now...

At this point, my note re. changing the path in the note on runtime distribution, will be important. The note was for CR XI r1, thus for CR XI r2, the path to the bin is c:\program files\business objects\common\3.5\bin.

Ludek

Former Member
0 Kudos

Ludek, I ment to imply that we are already developing reports in R2, just the application was compiled with R1 (from an older computer no longer in use).

Now both development of reports, and application, are on R2. And it is now that we are getting the Logon Failed. message when trying to dynamically switch XML sources. We do not see this message when we comment out the lines that switch sources.. so it is able to launch the base report.

Edit: We are applying the service packs now and will reply after we try to view the report with most recent updates. We were running SP 2, so we were a bit behind.

Edited by: Kurtas BB on Sep 23, 2008 2:33 PM

Former Member
0 Kudos

Okay we've upgraded to CR XI R2 SP4, and still getting the Login Failed message. I agree though that we are getting closer. Note that we only get this when switching XML source using the same code.

former_member183750
Active Contributor
0 Kudos

Let me tested here. I'll get back to you later today.

Ludek

former_member183750
Active Contributor
0 Kudos

Ok. Tested and it does work.

Here is what I did.

1) Create a report off of a "george.xml"; and "george.xsd";. "george.xml"; and "george.xsd"; are in C:\crystal\xml directory.

2) Ensured that "Save data with report" was not enabled.

3) Saved report as test_xml.rpt

4) Created a simple VB 6 app to run above report - works

5) Copied "george.xml"; and "george.xsd"; to C:\Crystal\test\

5) Renamed the "george.xml"; and "george.xsd"; in the C:\crystal\xml directory to "aaageorge.xml"; and "aaageorge.xsd";

6) Used code below to view the report - no errors

Set myReport = myApplication.OpenReport(CommonDialog1.FileName)

myReport.Database.Tables(1).ConnectionProperties("local xml file") = "C:\Crystal\test\george.xml";

myReport.Database.Tables(1).ConnectionProperties("local schema file") = "C:\Crystal\test\george.xsd";

CrystalActiveXReportViewer1.ReportSource = myReport

CrystalActiveXReportViewer1.ViewReport

So, I'm not sure what the difference may be between your app and mine, but perhaps you can try to copy and paste my code into a new project and see if that will work.

A bit on the RAS thread. For my money, I'd move over to RAS. RDC (craxdrt.dll) is a retired technology. E.G.; the RDC SDK does not ship in CR 2008. I believe CR XI r2 any "official"support runs out early next year. Patch support has been stopped about 1/2 a year. Thus, from a life cycle perspective, going with RAS may be the way to go. But, this is just an FYI - cards on the table, etc. You'll have to decide what's best for your requirements.

Ludek

Former Member
0 Kudos

Ludek, thanks for taking all this time to test our process, my co-developer is trying this now:

Our exact goal applied to your test setup would be this however, at Step 5, you renamed the XML file and XSD file.. good, now edit aaageorge.xml and change some of the element values within. And now have your VB app launch the report based on the data inside aaageorge.xml

Edit : specifically

myReport.Database.Tables(1).ConnectionProperties("local xml file") = "C:\Crystal\test\aaageorge.xml";

Do your changes appear in the VB 6 viewer?

My co-worker is trying this now as well.

Edited by: Kurtas BB on Sep 24, 2008 8:54 PM

Former Member
0 Kudos

Ludek, we just tested some of our sample data, we got it to work !!!! I wish we came to these forums a week sooner instead of pulling our hair out.

I will pursue the .NET / RAS thread as well, due to the RDC retirement issue.

Thanks again for your input!

former_member183750
Active Contributor
0 Kudos

Ok, just to make sure we're on the same page.

Report was created off of george.xml .One of the fields has names in it. I replaced "Johnson" with "Ludek" in the aaageorge.xml. Now this is the xml that should not be used by the report as my code is pointing at george.xml in another directory. After the change in aaageorge.xml, I still get "Johnson", thus proving that the report is reading the xml from the new directory.

I even deleted the directory that had the original xml / xsd that was used to create the report. So there is no question that the xml would be used. And I still get a report.

Ludek

Answers (0)