1 Replies - 1408 Views - Last Post: 20 November 2012 - 02:01 AM Rate Topic: ****- 1 Votes

#1 christian Mukeba  Icon User is offline

  • D.I.C Head

Reputation: -2
  • View blog
  • Posts: 96
  • Joined: 06-September 12

crystal reports in vb

Posted 19 November 2012 - 05:54 AM

i am trying to generate a CR from multiple tables based on the user textbox entry and i am getting this error "Invalid Index.(Exception from HRESULT:0X8002000B(DISP_E_BADINDEX))
can anyone know what is this means??
Here's my code
 Private Sub BtnUnitOrderReportOK_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnUnitOrderReportOK.Click
        EquipmentOrderForm.Show()

        Dim Dbcon As New SqlClient.SqlConnection(My.Settings.NewEvapcoDBConnectionString.ToString)
        Dim cmd As New SqlClient.SqlCommand("SELECT Accessorie_Items.AccessorieItems, Sound_Option_Items.SoundOptionItems, Construction_Option_Items.ConstructionOptionItems, [Unit Order].UnitSerialNumber,Shipment.ShipmentDescr, creditApproval.ApprovalDesc, Customers.CompanyName, Extra_ESP.ExtraESP_Descr, Larger_motor.LargerMotor, Model.Modelnumber, Refrigerant.RefrigerantDesc FROM  Accessorie_Items INNER JOIN [Unit Order] ON Accessorie_Items.UnitID=[Unit Order].UnitID INNER JOIN Construction_Option_Items ON [Unit Order].UnitID=Construction_Option_Items.UnitID INNER JOIN Sound_Option_Items ON [Unit Order].UnitID=Sound_Option_Items.UnitID INNER JOIN Shipment ON [Unit Order].ShipmentID=Shipment.ShipmentID INNER JOIN CreditApproval ON [Unit Order].CreditApprovalID=CreditApproval.CreditApprovalID INNER JOIN Customers ON [Unit Order].CustomerID=Customers.CustomerID INNER JOIN Extra_ESP ON [Unit Order].ExtraESP_ID=Extra_ESP.ExtraESP_ID INNER JOIN Larger_Motor ON [Unit Order].LargerMotorID=Larger_Motor.LargerMotorID INNER JOIN Model ON [Unit Order].ModelNumberID=Model.ModelNumberID INNER JOIN Refrigerant ON [Unit Order].RefrigerantID=Refrigerant.RefrigerantID WHERE [Unit Order].UnitSerialNumber Like '%" + TxtUnitSN.Text + "%'")

        Dim da As New SqlClient.SqlDataAdapter(cmd)
        Dim ds As New UnitOrderDataSet
        Dim strReportName As String = "UnitOrderReport"
        Dim rptdoc As New CrystalDecisions.CrystalReports.Engine.ReportDocument
        Dim strReportpath As String = ("D:\New EvapcoDB\New EvapcoDB\UnitOrderReport.Rpt")

        Try
            cmd.Connection = Dbcon
            Dbcon.Open()
            ds.Clear()
            da.Fill(ds, "UnitOrderdataset")
            If cmd.ExecuteNonQuery = False Then
                MsgBox("The Unit Serial Number is wrong", vbCritical, "Error")
            End If
            If Not IO.File.Exists(strReportpath) Then
                MsgBox("The report was not found", vbCritical, "Error")
                Dbcon.Close()
                Exit Sub
            End If

            rptdoc.Load(strReportpath)
            rptdoc.Database.Tables("[Unit Order]").SetDataSource(ds.Tables(1))
            rptdoc.Database.Tables("Customers").SetDataSource(ds.Tables(1))
            rptdoc.Database.Tables("Model").SetDataSource(ds.Tables(1))
            rptdoc.Database.Tables("CreditApproval").SetDataSource(ds.Tables(1))
            rptdoc.Database.Tables("Extra_ESP").SetDataSource(ds.Tables(1))
            rptdoc.Database.Tables("Larger_Motor").SetDataSource(ds.Tables(1))
            rptdoc.Database.Tables("Refrigerant").SetDataSource(ds.Tables(1))
            rptdoc.Database.Tables("shipment").SetDataSource(ds.Tables(1))
            rptdoc.Database.Tables("Sound_Option_Items").SetDataSource(ds.Tables(1))
            rptdoc.Database.Tables("Construction_Option_Items").SetDataSource(ds.Tables(1))
            rptdoc.Database.Tables("Accessorie_Items").SetDataSource(ds.Tables(1))
            rptdoc.Refresh()
            EquipmentOrderForm.UnitOrderReportViewer.ReportSource = rptdoc
            EquipmentOrderForm.UnitOrderReportViewer.Refresh()
        Catch ex As Exception
            System.Windows.Forms.MessageBox.Show(ex.Message)
        End Try
    End Sub

please help me!!!

This post has been edited by christian Mukeba: 19 November 2012 - 05:56 AM


Is This A Good Question/Topic? 0
  • +

Replies To: crystal reports in vb

#2 christian Mukeba  Icon User is offline

  • D.I.C Head

Reputation: -2
  • View blog
  • Posts: 96
  • Joined: 06-September 12

Re: crystal reports in vb

Posted 20 November 2012 - 02:01 AM

Is anyone willing to help me!!!please i don't know how to solve this???
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1