0

While trying to print an Invoice using Crystal Reports I get this error:

enter image description here

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))

Bugs
  • 4,491
  • 9
  • 32
  • 41
Subin
  • 1
  • 2
  • It's difficult to tell where the error is but after a quick look I did find [this](https://forums.asp.net/t/1178464.aspx) – Bugs Jun 08 '17 at 09:53
  • There is also an SO link [here](https://stackoverflow.com/questions/13356765/winforms-crystal-report-failed-to-load-database-information-error). It could be you need to install something. – Bugs Jun 08 '17 at 09:54
  • Ok.Let me try... – Subin Jun 08 '17 at 09:55
  • Thank you very much – Subin Jun 08 '17 at 09:55

0 Answers0