Posted 11 December 2017, 3:26 am EST
This code are working perfect with Spread 10
For i = 1 to 10
SQL = "SELECT * FROM CENTRAL WHERE CENTRAL = 'TEST" & i & "'"
Export()
Next
Private Sub Export()
Dim conn As OleDb.OleDbConnection = GetConnection()
Try
Dim sa As OleDb.OleDbDataAdapter = New OleDb.OleDbDataAdapter(SQL, conn)
Dim ds As New DataSet
Try
With FpSpread1.ActiveSheet
sa.Fill(ds)
.DataSource = ds
.AddColumns(0, 2)
End With
Catch Ex As System.Exception
sa.Dispose()
End Try
Finally
conn.Close()
conn.Dispose()
End Try
End Sub
But in Spread 11 I need to set .rowcount = 0
For i = 1 to 10
SQL = "SELECT * FROM CENTRAL WHERE CENTRAL = 'TEST" & i & "'"
Export()
Next
Private Sub Export()
Dim conn As OleDb.OleDbConnection = GetConnection()
Try
Dim sa As OleDb.OleDbDataAdapter = New OleDb.OleDbDataAdapter(SQL, conn)
Dim ds As New DataSet
Try
With FpSpread1.ActiveSheet
.RowCount = 0
sa.Fill(ds)
.DataSource = ds
.AddColumns(0, 2)
End With
Catch Ex As System.Exception
sa.Dispose()
End Try
Finally
conn.Close()
conn.Dispose()
End Try
End Sub
This is the error code:
System.IndexOutOfRangeException occurred
HResult=0x80131508
Message=Invalid index specified: 523\n(current length is 523)
Source=
StackTrace:
at ag.e(Int32 A_0)
at FarPoint.Win.Spread.SheetView.l(Int32 A_0, Boolean A_1)
at FarPoint.Win.Spread.SheetView.GetModelRowFromViewRow(Int32 row)
at bd.a(Int32 A_0, Int32 A_1, Int32 A_2, Int32 A_3, Boolean A_4, SortInfo A_5)
at FarPoint.Win.Spread.SheetView.a(Int32 A_0, Int32 A_1, SortInfo A_2, Boolean A_3, Boolean A_4, Int32 A_5, Int32& A_6, Boolean A_7)
at FarPoint.Win.Spread.SheetView.SortRows(Int32 row, Int32 rowCount, SortInfo sortInfo)
at Cadbim.Kraft_Gr.GruppschemaExport() in C:\Users\Projects \Project\Kraft_GR.vb:line 416
at Cadbim.Kraft_Gr.ButtonGenereraGruppscheman_Click(Object sender, EventArgs e) in C:\Users\Project\Kraft_GR.vb:line 384
at System.Windows.Forms.Control.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ButtonBase.WndProc(Message& m)
at System.Windows.Forms.Button.WndProc(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(IntPtr dwComponentID, Int32 reason, Int32 pvLoopData)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.RunDialog(Form form)
at System.Windows.Forms.Form.ShowDialog(IWin32Window owner)
at System.Windows.Forms.Form.ShowDialog()
at xxxxx.main.xxxxxxToolStripMenuItem_Click(Object sender, EventArgs e) in C:\Users\Patrik\Documents\Project\0_main.vb:line 570
at System.Windows.Forms.ToolStripItem.RaiseEvent(Object key, EventArgs e)
at System.Windows.Forms.ToolStripMenuItem.OnClick(EventArgs e)
at System.Windows.Forms.ToolStripItem.HandleClick(EventArgs e)
at System.Windows.Forms.ToolStripItem.HandleMouseUp(MouseEventArgs e)
at System.Windows.Forms.ToolStripItem.FireEventInteractive(EventArgs e, ToolStripItemEventType met)
at System.Windows.Forms.ToolStripItem.FireEvent(EventArgs e, ToolStripItemEventType met)
at System.Windows.Forms.ToolStrip.OnMouseUp(MouseEventArgs mea)
at System.Windows.Forms.ToolStripDropDown.OnMouseUp(MouseEventArgs mea)
at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ScrollableControl.WndProc(Message& m)
at System.Windows.Forms.ToolStrip.WndProc(Message& m)
at System.Windows.Forms.ToolStripDropDown.WndProc(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(IntPtr dwComponentID, Int32 reason, Int32 pvLoopData)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.OnRun()
at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.DoApplicationModel()
at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.Run(String commandLine)
at xxxxx.My.MyApplication.Main(String Args) in :line 81