Skip to Content
0
Former Member
Aug 26, 2011 at 04:36 PM

not loading data from dataset

50 Views

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.