cancel
Showing results for 
Search instead for 
Did you mean: 

not loading data from dataset

Former Member
0 Kudos

ok, not sure what's wrong here. But intention is to limit the data for the report to the dataset. Basically, I am creating a dataset , and then trying to set the datasource of the reportDocument to that dataset. However, the report is showing all the data from that particular table. Here's my code snippet(reptDoc is my instance of reportdocument)

Private Sub loadCrystalReportOld()

Dim dsdata As New System.Data.DataSet

Dim sqlcmm As SqlClient.SqlCommand

Dim daAdapter As New SqlClient.SqlDataAdapter

Dim cnn As New SqlClient.SqlConnection

cnn.ConnectionString = " server=XXX;" & _

"uid=XXX;password=XXX;database=XXX"

cnn.Open()

If cnn.State = ConnectionState.Open Then

sqlcmm = New SqlClient.SqlCommand("select * from dailylog where rundate >='8/24/2011'", cnn)

'only want data after 8/24/2011

daAdapter.SelectCommand = sqlcmm

daAdapter.Fill(dsData)

If dsData.Tables(0).Rows.Count > 0 Then

reptDoc.FileName = "l:\reports\ecase\dailylog.rpt"

SetLogon(myConnectionInfo, reptDoc)

reptDoc.SetDataSource(dsData)

reptDoc.Refresh()

CrystalReportViewer1.ReportSource = reptDoc

CrystalReportViewer1.Refresh()

CrystalReportViewer1.Dock = DockStyle.Fill

End If

sqlcmm.Dispose()

End If

End Sub

But the report is loaded with all the data in the table dailylog.

Accepted Solutions (1)

Accepted Solutions (1)

0 Kudos

Hello,

Try this:

reptDoc.FileName = "l:\reports\ecase\dailylog.rpt"

reptDoc.Refresh() ' this drops all saved info

reptDoc.SetDataSource(dsData) ' set the report to your DS

CrystalReportViewer1.ReportSource = reptDoc

rather than set location to the report to your DB and refreshing the report twice:

reptDoc.FileName = "l:\reports\ecase\dailylog.rpt"

SetLogon(myConnectionInfo, reptDoc)

reptDoc.SetDataSource(dsData)

reptDoc.Refresh()

CrystalReportViewer1.ReportSource = reptDoc

CrystalReportViewer1.Refresh()

I assume the report is based on XML and not a the database directly?

Don

Former Member
0 Kudos

Hi Don, I tried that but same outcome.

Regarding Report, Yes, it's based off DB.

Also,I don't know if it matters or not but these reports were created using 8.5 version of crystal reports.

0 Kudos

Ah, yes it does matter. As of CR 9 we completely rewrote our DB drivers and renamed them. You 8.5 reports are still trying to use the legacy connection info, DB info and driver name is saved in the report.

If you search here for ReplaceConnection_click you'll find sample code on how to update your reports to use your new DS.

You may want to save your DS to XML format, replace location info to XMl and then replace connection again to your DS. try variations to see what works best.

We've always recommended that you use the same report version with the same SDK version. From 9 to CR 2008 it doesn't make a difference but from 8.5 and older to 9 and above it will make a difference...

Also compensates for changes that the DB Makes have done in their various client engines also...

Don

Answers (1)

Answers (1)

former_member183750
Active Contributor
0 Kudos

Se if the blog [Troubleshooting Issues with VS .NET Datasets and Crystal Reports|https://www.sdn.sap.com/irj/scn/weblogs?blog=/pub/wlg/13270] [original link is broken] [original link is broken] [original link is broken]; helps.

Ludek

Follow us on Twitter http://twitter.com/SAPCRNetSup

Got Enhancement ideas? Try the [SAP Idea Place|https://ideas.sap.com/community/products_and_solutions/crystalreports]