I'm kind of new to Crystal Reports so please bear with me. I know this is a pretty simple one but I'm having a time figuring it out.
I need to create a dynamic report that gets parameters from a winform. I dragged the fields onto the report from the Field Explorer and then created my DataSet which I loaded right after the InitializeComponent() call on the viewer form:
The report runs, but I get this database login screen right before it runs asking for the password to the database -- which I've already supplied in my connection string.
The problem is that it's not using my datasource, it's just running the report for the whole table instead of just the filtered records within the date range I specified in my DataSet.
If I don't drag the fields onto the report, it has no data. How do I get it to bind to my DataSet instead of doing its own thing ?
I need to create a dynamic report that gets parameters from a winform. I dragged the fields onto the report from the Field Explorer and then created my DataSet which I loaded right after the InitializeComponent() call on the viewer form:
Code:
InitializeComponent()
'Add any initialization after the InitializeComponent() call
Dim rep As New Reports, str, cs, sql, sReportSource, arr(2) As String, ds As DataSet
Dim c As New Connection, cnn As SqlConnection, cmd As SqlDataAdapter
cs = c.GetConnection
cnn = New SqlConnection(cs)
cnn.Open()
If rep.optSubmitted.Checked Then
arr(0) = "Submitted.rpt"
Else
arr(0) = "Rejected.rpt"
End If
arr(1) = rep.txtFromDate.Text
arr(2) = rep.txtToDate.Text
sql = "Select Invoice, Extended, DateSubmitted From Shell where DateSubmitted >= '" & arr(1) & "' and DateSubmitted <= '" & arr(2) & "' order by Invoice"
cmd = New SqlDataAdapter(sql, cnn)
ds = New DataSet
Try
cmd.Fill(ds)
sReportSource = "C:\ServiceEntry\" & arr(0) 'Submitted.rpt
rpt.SetDataSource(ds)
Me.CrystalReportViewer1.ReportSource = sReportSource
Catch ex As SqlException
MessageBox.Show(ex.Message, "Exception - Viewer_Load", MessageBoxButtons.OK, MessageBoxIcon.Error)
Finally
cnn.Close()
cnn.Dispose()
End Try
The report runs, but I get this database login screen right before it runs asking for the password to the database -- which I've already supplied in my connection string.
The problem is that it's not using my datasource, it's just running the report for the whole table instead of just the filtered records within the date range I specified in my DataSet.
If I don't drag the fields onto the report, it has no data. How do I get it to bind to my DataSet instead of doing its own thing ?