Question Help with connecting Datasets based on xml with crystal report

victor64

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

I'm getting the following error on the code below

" Identifier is expected "

On line:

"myaop29report.SetDataSource(dtset1.tables[0])"


Any ideas on how to fix this problem??

Code:

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

Dim xyzcal As String
xyzcal = Trim(TextBox1.Text)
Dim myaop29report As New AOP29_XML
Dim mySQL_Statement As String

Dim fs1 As System.IO.FileStream
'fs1 = New System.IO.FileStream(Application.StartupPath + "\Link.xml", IO.FileMode.Open)
'mySQL_Statement = "{Link.Receiver_ID}in [" & xyzcal & "]"
'Dim myDataAdapter As New Xml.XmlTextReader(fs1)
'Dim dtset1 As New DataSet
'dtset1.ReadXml(fs1)
'myaop29report.SetDataSource(dtset1)
'myaop29report.RecordSelectionFormula = mySQL_Statement
'Me.Cursor = Cursors.Default
'myaop29report = Nothing

fs1 = New System.IO.FileStream(Application.StartupPath + "\Link.xml", IO.FileMode.Open)
mySQL_Statement = "{Link.Receiver_ID}in [" & xyzcal & "]"
Dim myDataAdapter As New Xml.XmlTextReader(fs1)
Dim dtset1 As New DataSet
dtset1.ReadXml(myDataAdapter)
myaop29report.SetDataSource(dtset1.tables[0])

Any ideas on how to fix this problem?

Also when I use the following code, I receive error message "Root element" is missing

Code:

Dim xyzcal As String
xyzcal = Trim(TextBox1.Text)
Dim myaop29report As New AOP29_XML
Dim mySQL_Statement As String
Dim fs1 As System.IO.FileStream
fs1 = New System.IO.FileStream(Application.StartupPath + "\Link.xml", IO.FileMode.Open)
mySQL_Statement = "{Link.Receiver_ID}in [" & xyzcal & "]"
Dim myDataAdapter As New Xml.XmlTextReader(fs1)
Dim dtset1 As New DataSet
dtset1.ReadXml(fs1)
myaop29report.SetDataSource(dtset1)
myaop29report.RecordSelectionFormula = mySQL_Statement
Me.Cursor = Cursors.Default
myaop29report = Nothing

Thanks,

Victor
 
Please keep each thread to a single topic and each topic to a single thread. If you want to add more information add another post to the same thread. If you think you've posted in the wrong forum then ask the mods to move your thread.
 
"myaop29report.SetDataSource(dtset1.tables[0])"


Any ideas on how to fix this problem??

Given that myaop29report is a custom class that you wrote:

Dim myaop29report As New AOP29_XML

..that I've never seen before, and for which no online documentation exists, the answer would be a rather succinct "no" from me..
 
The correct syntax is myaop29report.SetDataSource(dtset1.tables(0))", problem is, I'm getting prompted for a password eventhough my report
is not connected to a password protected datasource, it's datasource are XML files.
 
Heh.. Yes.. I work nearly exclusively in C#, so the tables[0] is how i'd write it in C# and I skipped over it completely as being erroneous.. Sorry about that

Was the report designed by being connected to a password protected datasource? Could it have the connection string or similar still embedded in it?
 
Hello asgain,

The correct syntax is myaop29report.SetDataSource(dtset1.tables(0))", problem is, I'm getting prompted for a password eventhough my report is not connected to a password protected datasource, it's datasource are XML files.

Can you please help me fix this problem.


Code:

Dim myaop6viewer As New AOP6VIEWER
Dim xyzcal As String
xyzcal = Trim(TextBox1.Text)
Dim myaop29report As New AOP29_XML
Dim mySQL_Statement As String
Dim fs1 As System.IO.FileStream
fs1 = New System.IO.FileStream(Application.StartupPath + "\Link.xml", IO.FileMode.Open)
mySQL_Statement = "{Link.Receiver_ID}in [" & xyzcal & "]"
Dim myDataAdapter As New Xml.XmlTextReader(fs1)
Dim dtset1 As New DataSet
dtset1.ReadXml(myDataAdapter)
myaop29report.SetDataSource(dtset1.Tables(0))
With myaop6viewer
.CrystalViewer1.ReportSource = myaop29report
.Show()
End With
MsgBox(myaop29report.RecordSelectionFormula)
Me.Cursor = Cursors.Default
myaop29report = Nothing

Thanks,

Victor
 
Hi,

I'm trying a different approach below, but I'm getting the following error:

Format of the initialization string does not conform to specification starting at index 0.

in line: adoOleDbDataAdapter = New OleDbDataAdapter(sqlString, fs1.ToString)

Dim myaop6viewer As New AOP6VIEWER
Dim xyzcal As String
xyzcal = Trim(TextBox1.Text)
Dim crReportDocument As New AOP29_XML
Dim DataSet1 As New DataSet
Dim adoOleDbConnection As New OleDbConnection
Dim adoOleDbDataAdapter As New OleDbDataAdapter
Dim fs1 As System.IO.FileStream
fs1 = New System.IO.FileStream(Application.StartupPath + "\Link.xml", IO.FileMode.Open)
Dim sqlString As String
sqlString = "{Link.Receiver_ID}in [" & xyzcal & "]"
adoOleDbDataAdapter = New OleDbDataAdapter(sqlString, fs1.ToString)
DataSet1 = New DataSet()
DataSet1.ReadXml(fs1)
adoOleDbDataAdapter.Fill(DataSet1, "Link")
crReportDocument.Database.Tables(0).SetDataSource(DataSet1)
With myaop6viewer
.CrystalViewer1.ReportSource = crReportDocument
.Show()
End With

How can I solve this problem?

Thanks,

Victor
 
Back
Top