We're a community of 1077K IT Pros here for help, advice, solutions, professional growth and fun. Join us!
1,076,374 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Start New Discussion Reply to this Discussion

Problem printing a crystal report

I had this little project of a POS System, that i've already finished, and i try to retake it again to add more features

And suddenly in a Summary Report for the sales of the day i keep getting this error message

Exception from HRESULT: 0x8002000B (DISP_E_BADINDEX)

And im cranking my head in to figuring out what is wrong, please help!!

the error starts in the PrintToPrinter method

rptDocument.PrintToPrinter(1, False, 0, 0)

Here is my code that controls that button

connection.ConnectionString = (My.Settings.mainConnectionString.ToString)
                'command.CommandText = "SELECT idDepto,descripcion,total FROM RVentas WHERE(fecha = '" & TextBox1.Text & "');"
                command.CommandText = "INSERT INTO RVentas (idDepto, tipo, descripcion, total, fecha) SELECT departamento.Id AS ID,VentasDD.tipo AS Tipo, departamento.Nombre AS Departamento, SUM(VentasDD.Importe) AS Total, VentasDD.fecha FROM departamento INNER JOIN VentasDD ON departamento.Id = VentasDD.IdDepto GROUP BY VentasDD.tipo, VentasDD.fecha, departamento.Id, departamento.Nombre HAVING (VentasDD.fecha = '" & TextBox1.Text & "') AND (VentasDD.tipo ='V');"

                connection.Open()

                command.Connection = connection
                command.ExecuteNonQuery()
                adaptador.SelectCommand = command


                command.CommandText = "SELECT idDepto,descripcion,total FROM RVentas WHERE(fecha = '" & TextBox1.Text & "');"
                adaptador.SelectCommand = command
                adaptador.Fill(dataset, "0")
                DataGridView1.DataSource = dataset.Tables(0)


                strreportname = "RVentas"

                'Get the Report Location
                Dim strReportPath As String = "C:\" & strreportname & ".rpt"
                'Check file exists
                If Not IO.File.Exists(strReportPath) Then
                    Throw (New Exception("Unable to locate report file:" & vbCrLf & strReportPath))
                End If
                'Assign the datasource and set the properties for Report viewer
                Dim rptDocument As New CrystalDecisions.CrystalReports.Engine.ReportDocument

                rptDocument.Load(strReportPath)
                'rptDocument.SetDatabaseLogon("admin", "ehvgem")
                rptDocument.SetDataSource(dataset.Tables(0))

                CrystalReportViewer1.ShowRefreshButton = False
                CrystalReportViewer1.ShowCloseButton = False
                CrystalReportViewer1.ShowGroupTreeButton = False
                CrystalReportViewer1.ReportSource = rptDocument

                'Print
                margins = rptDocument.PrintOptions.PageMargins
                margins.bottomMargin = 1
                margins.leftMargin = 0.1
                margins.rightMargin = 0.1
                margins.topMargin = 0.25
                rptDocument.PrintOptions.ApplyPageMargins(margins)


                rptDocument.PrintToPrinter(1, False, 0, 0)

                command.CommandText = "DELETE FROM RVentas;"

                command.Connection = connection
                command.ExecuteNonQuery()
                adaptador.SelectCommand = command

Thanks in Advance!!

1
Contributor
1
Reply
47 Minutes
Discussion Span
1 Year Ago
Last Updated
2
Views
CrankyMero
Newbie Poster
24 posts since Jan 2011
Reputation Points: 10
Solved Threads: 2
Skill Endorsements: 0

So i managed to get the ex.Message and got the following image that i added to this reply, also i know that the margins are correct and everything!, I have the same method when printing a purchase receipt and it doesnt give me any problems

only on the summary

Attachments Cajero_Error.png 27.75KB
CrankyMero
Newbie Poster
24 posts since Jan 2011
Reputation Points: 10
Solved Threads: 2
Skill Endorsements: 0

This article has been dead for over three months: Start a new discussion instead

Post: Markdown Syntax: Formatting Help
 
You
View similar articles that have also been tagged:
 
© 2013 DaniWeb® LLC
Page rendered in 0.0603 seconds using 2.66MB