Question How to view a report with an XMl data source?

victor64

Well-known member
Joined
Nov 9, 2008
Messages
60
Programming Experience
Beginner
Hello,

I'm using XML as a data source for my report, the report works ok by itself, however when attempting to run it using VB.Net, I receive a prompt for login and password, problem is the xml files are not password protected, seems like it can't find the xml files, please help me fix this problem. I am using Crystal Repory XI Release 2 with VS 2008.

Below is my code, and example of the content of the xml files. I am selecing the receiver/Donor nations' ID from a grid and copying it to textbox2, the code was simplified to focus on the problem.

1. Doner.xml

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<Root xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<Row>
<Donor_ID>1</Donor_ID>
<Donor>BEL</Donor>
</Row>
<Row>
<Donor_ID>2</Donor_ID>
<Donor>CAN</Donor>
</Row>
</Root>


2. Receiver.xml

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<Root xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<Row>
<Receiver_ID>1</Receiver_ID>
<Receiver>FRA</Receiver>
</Row>
<Row>
<Receiver_ID>2</Receiver_ID>
<Receiver>GBR</Receiver>
</Row>
<Row>
<Receiver_ID>3</Receiver_ID>
<Receiver>NLD</Receiver>
</Row>
<Row>
<Receiver_ID>4</Receiver_ID>
<Receiver>DEU</Receiver>
</Row>
<Row>
<Receiver_ID>5</Receiver_ID>
<Receiver>USA</Receiver>
</Row>
</Root>


3. Link.xml

<?xml version="1.0" standalone="yes"?>
<DocumentElement>
<Row>
<Link_ID>1</Link_ID>
<Receiver_ID>1</Receiver_ID>
<Donor_ID>1</Donor_ID>
</Row>
<Row>
<Link_ID>2</Link_ID>
<Receiver_ID>2</Receiver_ID>
<Donor_ID>1</Donor_ID>
</Row>
</DocumentElement>

Thanks,


4. Code

Imports System.Xml.Linq
Imports System.Data.OleDb
Imports Microsoft.VisualBasic.ControlChars
Imports CrystalDecisions.Shared
Imports CrystalDecisions.CrystalReports.Engine
Public Class Form2

Private Sub Form2_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Me.CenterToScreen()
End Sub
Private Sub Button6_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button6.Click
Dim myviewer As New AOP29VIEWER
Dim myreport As New AOP29_XML
Dim SearchCriteria As String
SearchCriteria = "{Link.Receiver_ID} in [" & TextBox2.Text & "] "
myreport.RecordSelectionFormula = SearchCriteria
MsgBox(myreport.RecordSelectionFormula)
Me.Visible = False
With myviewer
.CrystalViewer1.ReportSource = myreport
.ShowIcon = False
.Show()
End With
Me.Cursor = Cursors.Default
myreport = Nothing
End Sub

Thanks

Victor
 

Attachments

  • LOADXML2.zip
    35.9 KB · Views: 19
Last edited by a moderator:
When I use Crystal Reports, I load any data I want to show, into a DataSet and give that to Crystal to show.. Many times in my life I've grown tired of trying to make crystal go and get the data that I tell it to
 
Hello,

Can you please send me a short example, this approach usually works with an access database, still can figure out how do you use the selection formula when using a dataset with xml.

Thanks,

Victor
 
Hello,

I'm trying to read the data to a dataset and pass it to crystal report the code below, but can't figure out the complete code, can you please help me complete the code.

Dim myviewer As New AOP29VIEWER
Dim myreport As New AOP29_XML
Dim AuthorsDataSet As New DataSet
Dim filePath As String = "C:\link.xml"
AuthorsDataSet.ReadXml(filePath)
myreport.RecordSelectionFormula = ????? (AuthorsDataSet)
With myviewer
.CrystalViewer1.ReportSource = myreport
.ShowIcon = False
.Show()
End With


Thanks,

Victor
 

Latest posts

Back
Top