Crystal problem

C

Chubbly Geezer

I have the following function in my app (2005) that should be loading a form
and populating a crystal report contained by a crystal report viewer.

I have an almost identical piece of code in another app (.Net) which works
fine, however when this report is displayed it contains no data. Can't
really see why. Can anyone help?

Public Function PrintReports(ByVal strSQL As String, ByVal strSelect As
String, ByVal strReportName As String, ByVal strXSDName As String) As
Integer

Try

Dim myRptString As String = strReportRoot & strReportName

Dim myXsdTable As String = strXSDName

Dim oleConn As New System.Data.OleDb.OleDbConnection(strConnADO)

Dim oleAdapter As New System.Data.OleDb.OleDbDataAdapter()

Dim myDataset As New DataSet()

Dim myReport As New CrystalReport1

Dim myForm As New frmCrystalViewer

Dim objClass As New clsSQL

If objClass.RunPassedSQL("Delete From SubscriptionsPrintQueue") = False Then
GoTo CatchError ' Deletes data records in table

If objClass.RunPassedSQL(strSQL) = False Then GoTo CatchError ' Populates
data in table

objClass = Nothing

oleAdapter.SelectCommand = New System.Data.OleDb.OleDbCommand(strSelect,
oleConn)

' Connect to the data source, fetch the data, and disconnect from the
database.

oleAdapter.Fill(myDataset, myXsdTable)

MessageBox.Show(myDataset.Tables(0).Rows.Count) ' Shows over 35k records

With myReport

..SetDataSource(myDataset)

..Refresh()

MessageBox.Show(.Rows.Count) ' Shows 0 records

End With

With myForm

..CrystalReportViewer1.ReportSource = myReport

..CrystalReportViewer1.DisplayGroupTree = False

..CrystalReportViewer1.Refresh()

..CrystalReportViewer1.RefreshReport()

..CrystalReportViewer1.Visible = True

..Show()

End With

Catch objE As Exception

MessageBox.Show(objE.Message & vbCrLf & vbCrLf & "Please contact your IT
department.", "Error encountered ==> clsCrystal:printReports",
MessageBoxButtons.OK, MessageBoxIcon.Error)

GoTo catcherror

End Try

TheExit:

Exit Function

CatchError:

GoTo TheExit

End Function
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top