Ссылка на объект не указывает на экземпляр объекта при загрузке отчета Crystal
Я создаю форму счета-фактуры в vb.net но для печати я пытаюсь загрузить crystal report, и это дает мне ошибку.
Что я уже пробовал:
Sub Print() Try Cursor = Cursors.WaitCursor Timer1.Enabled = True Dim rpt As New rptInvoice 'The report you created. Dim myConnection As MySqlConnection Dim MyCommand, MyCommand1 As New MySqlCommand() Dim myDA, myDA1 As New MySqlDataAdapter() Dim myDS As New DataSet 'The DataSet you created. myConnection = New MySqlConnection(cs) MyCommand.Connection = myConnection MyCommand1.Connection = myConnection MyCommand.CommandText = "SELECT tblcustomer.ID, tblcustomer.cust_name, tblcustomer.address, tblcustomer.state, tblinvoice.Inv_ID, tblinvoice.InvoiceNo, tblinvoice.InvoiceDate, tblinvoice.CustomerID , tblinvoice.GrandTotal, tblinvoice_product.InvP_ID, tblinvoice_product.InvoiceID, tblinvoice_product.ProductID, tblinvoice_product.CostPrice, tblinvoice_product.Qty, tblinvoice_product.Amount, tblinvoice_product.TotalAmount, tblproduct.PID, tblproduct.ProductName, tblproduct.SubCategory, tblproduct.HSNCode, tblproduct.IGST FROM tblcustomer INNER JOIN tblinvoice ON tblcustomer.ID = tblinvoice.CustomerID INNER JOIN tblinvoice_product ON tblinvoice.Inv_ID = tblinvoice_product.InvoiceID INNER JOIN tblproduct ON tblinvoice_product.ProductID = tblproduct.PID where tblinvoice.Inv_ID=@d1" MyCommand.Parameters.AddWithValue("@d1", txtInvoiceID.Text) MyCommand1.CommandText = "SELECT * from tblcompany" MyCommand.CommandType = CommandType.Text MyCommand1.CommandType = CommandType.Text myDA.SelectCommand = MyCommand myDA1.SelectCommand = MyCommand1 myDA.Fill(myDS, "tblinvoice") myDA.Fill(myDS, "tblinvoice_product") myDA.Fill(myDS, "tblproduct") myDA.Fill(myDS, "tblcustomer") myDA1.Fill(myDS, "tblcompany") rpt.SetDataSource(myDS) rpt.SetParameterValue("p1", txtCustid.Text) rpt.SetParameterValue("p2", txtInvoiceID.Text) ' rpt.SetParameterValue("p2", Today) frmReport.CrystalReportViewer1.ReportSource = rpt frmReport.ShowDialog() Catch ex As Exception MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error) End Try End Sub