While trying to print an Invoice using Crystal Reports I get this error:
This is my code:
Private Sub btn_print_Click(sender As Object, e As EventArgs) Handles btn_print.Click
Dim str As String = My.Settings.DatabaseNameConnectionString
Dim con As New SqlConnection(str)
Dim com As String = "select Name,SUM(Total),SUM(Quantity),SUM(Discount),SUM(Tax) from purchase group by Name"
Dim adpt As New SqlDataAdapter(com, con)
Dim ds As New DataSet()
adpt.Fill(ds, "purchase")
cr1.SetDataSource(dgv_purchase.DataSource)
purchaseReport.CrystalReportViewer1.ReportSource = cr1
purchaseReport.CrystalReportViewer1.RefreshReport()
purchaseReport.ShowDialog()
End Sub
As per OP's comment:
Query runs OK in SSMS and the error still occurs when changing cr1.SetDataSource(dgv_purchase.DataSource)
to cr1.SetDataSource(ds.Tables(0))