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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Help with connecting Datasets based on xml with crystal report

Status
Not open for further replies.

ITWORKER2010

IS-IT--Management
Aug 18, 2010
5
0
0
US
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(myDataAdapter)
myaop29report.SetDataSource(dtset1.tables[0])

I'm using VB.NET (VS2008) with crystal report 2008.

Thanks,

Victor
 
In any case, tables[0] is c# style, in vb.net, it should read tables(0).
 
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

Victor
 
Try explicitly cast the argument to DataTable:
[tt] myaop29report.SetDataSource(CType(dtset1.Tables(0),DataTable))[/tt]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top