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