An unexcepted exception occurs when I call DataRowCollection.Add
up vote
0
down vote
favorite
In the following code:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data.SQLite;
using System.Diagnostics;
namespace WindowsFormsApplication1
{
public partial class List : Form
{
public List()
{
InitializeComponent();
}
private void List_Load(object sender, EventArgs e)
{
comboBox1.SelectedIndex = 1;
}
private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
{
var cmd = new SQLiteCommand("select * from students", DB.Connection);
var ad = new SQLiteDataAdapter(cmd);
var dt = new DataTable();
ad.Fill(dt);
listBox1.DataSource = dt;
listBox1.DisplayMember = "name";
}
private void btnAdd_Click(object sender, EventArgs e)
{
Debug.Assert(listBox1.DataSource is DataTable);
var dt = listBox1.DataSource as DataTable;
dt.Rows.Add();
btnEdit.Enabled = btnRemove.Enabled = dt.Rows.Count != 0;
}
private void btnEdit_Click(object sender, EventArgs e)
{
Debug.Assert(listBox1.SelectedItem is DataRowView);
new StudentsForm2(listBox1.SelectedItem as DataRowView).ShowDialog(this);
}
private void btnRemove_Click(object sender, EventArgs e)
{
Debug.Assert(listBox1.DataSource is DataTable);
var dt = listBox1.DataSource as DataTable;
dt.Rows.RemoveAt(listBox1.SelectedIndex);
btnEdit.Enabled = btnRemove.Enabled = dt.Rows.Count != 0;
}
private void List_KeyDown(object sender, KeyEventArgs e)
{
if (e.KeyCode == Keys.Escape)
{
Close();
}
}
}
}
when the table is empty, I get the following exception:
A first chance exception of type 'System.ArgumentOutOfRangeException' occurred in System.Windows.Forms.dll
Additional information: InvalidArgument=Value of '0' is not valid for 'SelectedIndex'.
in method btnAdd_Click when it calls dt.Rows.Add(). comboBox1 holds tables names, but since I only have one table at the moment it's not used unless for comboBox1_SelectedIndexChanged to be called.
Here's the stack trace at the point the exception is thrown:
at System.Environment.GetStackTrace(Exception e, Boolean needFileInfo)
at System.Environment.get_StackTrace()
at System.Windows.Forms.ListBox.set_SelectedIndex(Int32 value)
at System.Windows.Forms.ListControl.DataManager_PositionChanged(Object sender, EventArgs e)
at System.Windows.Forms.CurrencyManager.OnPositionChanged(EventArgs e)
at System.Windows.Forms.CurrencyManager.ChangeRecordState(Int32 newPosition, Boolean validating, Boolean endCurrentEdit, Boolean firePositionChange, Boolean pullData)
at System.Windows.Forms.CurrencyManager.List_ListChanged(Object sender, ListChangedEventArgs e)
at System.Data.DataView.OnListChanged(ListChangedEventArgs e)
at System.Data.DataView.IndexListChanged(Object sender, ListChangedEventArgs e)
at System.Data.DataView.IndexListChangedInternal(ListChangedEventArgs e)
at System.Data.DataViewListener.IndexListChanged(ListChangedEventArgs e)
at System.Data.Index.<>c.b__88_0(DataViewListener listener, ListChangedEventArgs args, Boolean arg2, Boolean arg3)
at System.Data.Listeners1.Notify[T1,T2,T3](T1 arg1, T2 arg2, T3 arg3, Action
4 action)
at System.Data.Index.OnListChanged(ListChangedEventArgs e)
at System.Data.Index.OnListChanged(ListChangedType changedType, Int32 index)
at System.Data.Index.InsertRecord(Int32 record, Boolean fireEvent)
at System.Data.Index.ApplyChangeAction(Int32 record, Int32 action, Int32 changeRecord)
at System.Data.Index.RecordStateChanged(Int32 record, DataViewRowState oldState, DataViewRowState newState)
at System.Data.DataTable.RecordStateChanged(Int32 record1, DataViewRowState oldState1, DataViewRowState newState1, Int32 record2, DataViewRowState oldState2, DataViewRowState newState2)
at System.Data.DataTable.SetNewRecordWorker(DataRow row, Int32 proposedRecord, DataRowAction action, Boolean isInMerge, Boolean suppressEnsurePropertyChanged, Int32 position, Boolean fireEvent, Exception& deferredException)
at System.Data.DataTable.InsertRow(DataRow row, Int64 proposedID, Int32 pos, Boolean fireEvent)
at System.Data.DataRowCollection.Add(Object values)
at WindowsFormsApplication1.List.btnAdd_Click(Object sender, EventArgs e) in C:UsershamidiDocumentsVisual Studio 2010Projectsm_rezaeeWindowsFormsApplication1WindowsFormsApplication1List.cs:line 44
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.Run(Form mainForm)
at WindowsFormsApplication1.Program.Main() in C:UsershamidiDocumentsVisual Studio 2010Projectsm_rezaeeWindowsFormsApplication1WindowsFormsApplication1Program.cs:line 18
at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String args)
at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String args)
at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()
I couldn't find any clue about why it happens.
c# datatable system.data.sqlite indexoutofrangeexception
add a comment |
up vote
0
down vote
favorite
In the following code:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data.SQLite;
using System.Diagnostics;
namespace WindowsFormsApplication1
{
public partial class List : Form
{
public List()
{
InitializeComponent();
}
private void List_Load(object sender, EventArgs e)
{
comboBox1.SelectedIndex = 1;
}
private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
{
var cmd = new SQLiteCommand("select * from students", DB.Connection);
var ad = new SQLiteDataAdapter(cmd);
var dt = new DataTable();
ad.Fill(dt);
listBox1.DataSource = dt;
listBox1.DisplayMember = "name";
}
private void btnAdd_Click(object sender, EventArgs e)
{
Debug.Assert(listBox1.DataSource is DataTable);
var dt = listBox1.DataSource as DataTable;
dt.Rows.Add();
btnEdit.Enabled = btnRemove.Enabled = dt.Rows.Count != 0;
}
private void btnEdit_Click(object sender, EventArgs e)
{
Debug.Assert(listBox1.SelectedItem is DataRowView);
new StudentsForm2(listBox1.SelectedItem as DataRowView).ShowDialog(this);
}
private void btnRemove_Click(object sender, EventArgs e)
{
Debug.Assert(listBox1.DataSource is DataTable);
var dt = listBox1.DataSource as DataTable;
dt.Rows.RemoveAt(listBox1.SelectedIndex);
btnEdit.Enabled = btnRemove.Enabled = dt.Rows.Count != 0;
}
private void List_KeyDown(object sender, KeyEventArgs e)
{
if (e.KeyCode == Keys.Escape)
{
Close();
}
}
}
}
when the table is empty, I get the following exception:
A first chance exception of type 'System.ArgumentOutOfRangeException' occurred in System.Windows.Forms.dll
Additional information: InvalidArgument=Value of '0' is not valid for 'SelectedIndex'.
in method btnAdd_Click when it calls dt.Rows.Add(). comboBox1 holds tables names, but since I only have one table at the moment it's not used unless for comboBox1_SelectedIndexChanged to be called.
Here's the stack trace at the point the exception is thrown:
at System.Environment.GetStackTrace(Exception e, Boolean needFileInfo)
at System.Environment.get_StackTrace()
at System.Windows.Forms.ListBox.set_SelectedIndex(Int32 value)
at System.Windows.Forms.ListControl.DataManager_PositionChanged(Object sender, EventArgs e)
at System.Windows.Forms.CurrencyManager.OnPositionChanged(EventArgs e)
at System.Windows.Forms.CurrencyManager.ChangeRecordState(Int32 newPosition, Boolean validating, Boolean endCurrentEdit, Boolean firePositionChange, Boolean pullData)
at System.Windows.Forms.CurrencyManager.List_ListChanged(Object sender, ListChangedEventArgs e)
at System.Data.DataView.OnListChanged(ListChangedEventArgs e)
at System.Data.DataView.IndexListChanged(Object sender, ListChangedEventArgs e)
at System.Data.DataView.IndexListChangedInternal(ListChangedEventArgs e)
at System.Data.DataViewListener.IndexListChanged(ListChangedEventArgs e)
at System.Data.Index.<>c.b__88_0(DataViewListener listener, ListChangedEventArgs args, Boolean arg2, Boolean arg3)
at System.Data.Listeners1.Notify[T1,T2,T3](T1 arg1, T2 arg2, T3 arg3, Action
4 action)
at System.Data.Index.OnListChanged(ListChangedEventArgs e)
at System.Data.Index.OnListChanged(ListChangedType changedType, Int32 index)
at System.Data.Index.InsertRecord(Int32 record, Boolean fireEvent)
at System.Data.Index.ApplyChangeAction(Int32 record, Int32 action, Int32 changeRecord)
at System.Data.Index.RecordStateChanged(Int32 record, DataViewRowState oldState, DataViewRowState newState)
at System.Data.DataTable.RecordStateChanged(Int32 record1, DataViewRowState oldState1, DataViewRowState newState1, Int32 record2, DataViewRowState oldState2, DataViewRowState newState2)
at System.Data.DataTable.SetNewRecordWorker(DataRow row, Int32 proposedRecord, DataRowAction action, Boolean isInMerge, Boolean suppressEnsurePropertyChanged, Int32 position, Boolean fireEvent, Exception& deferredException)
at System.Data.DataTable.InsertRow(DataRow row, Int64 proposedID, Int32 pos, Boolean fireEvent)
at System.Data.DataRowCollection.Add(Object values)
at WindowsFormsApplication1.List.btnAdd_Click(Object sender, EventArgs e) in C:UsershamidiDocumentsVisual Studio 2010Projectsm_rezaeeWindowsFormsApplication1WindowsFormsApplication1List.cs:line 44
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.Run(Form mainForm)
at WindowsFormsApplication1.Program.Main() in C:UsershamidiDocumentsVisual Studio 2010Projectsm_rezaeeWindowsFormsApplication1WindowsFormsApplication1Program.cs:line 18
at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String args)
at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String args)
at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()
I couldn't find any clue about why it happens.
c# datatable system.data.sqlite indexoutofrangeexception
duplicate: stackoverflow.com/questions/5274357/…
– JohnB
Nov 20 at 5:32
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
In the following code:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data.SQLite;
using System.Diagnostics;
namespace WindowsFormsApplication1
{
public partial class List : Form
{
public List()
{
InitializeComponent();
}
private void List_Load(object sender, EventArgs e)
{
comboBox1.SelectedIndex = 1;
}
private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
{
var cmd = new SQLiteCommand("select * from students", DB.Connection);
var ad = new SQLiteDataAdapter(cmd);
var dt = new DataTable();
ad.Fill(dt);
listBox1.DataSource = dt;
listBox1.DisplayMember = "name";
}
private void btnAdd_Click(object sender, EventArgs e)
{
Debug.Assert(listBox1.DataSource is DataTable);
var dt = listBox1.DataSource as DataTable;
dt.Rows.Add();
btnEdit.Enabled = btnRemove.Enabled = dt.Rows.Count != 0;
}
private void btnEdit_Click(object sender, EventArgs e)
{
Debug.Assert(listBox1.SelectedItem is DataRowView);
new StudentsForm2(listBox1.SelectedItem as DataRowView).ShowDialog(this);
}
private void btnRemove_Click(object sender, EventArgs e)
{
Debug.Assert(listBox1.DataSource is DataTable);
var dt = listBox1.DataSource as DataTable;
dt.Rows.RemoveAt(listBox1.SelectedIndex);
btnEdit.Enabled = btnRemove.Enabled = dt.Rows.Count != 0;
}
private void List_KeyDown(object sender, KeyEventArgs e)
{
if (e.KeyCode == Keys.Escape)
{
Close();
}
}
}
}
when the table is empty, I get the following exception:
A first chance exception of type 'System.ArgumentOutOfRangeException' occurred in System.Windows.Forms.dll
Additional information: InvalidArgument=Value of '0' is not valid for 'SelectedIndex'.
in method btnAdd_Click when it calls dt.Rows.Add(). comboBox1 holds tables names, but since I only have one table at the moment it's not used unless for comboBox1_SelectedIndexChanged to be called.
Here's the stack trace at the point the exception is thrown:
at System.Environment.GetStackTrace(Exception e, Boolean needFileInfo)
at System.Environment.get_StackTrace()
at System.Windows.Forms.ListBox.set_SelectedIndex(Int32 value)
at System.Windows.Forms.ListControl.DataManager_PositionChanged(Object sender, EventArgs e)
at System.Windows.Forms.CurrencyManager.OnPositionChanged(EventArgs e)
at System.Windows.Forms.CurrencyManager.ChangeRecordState(Int32 newPosition, Boolean validating, Boolean endCurrentEdit, Boolean firePositionChange, Boolean pullData)
at System.Windows.Forms.CurrencyManager.List_ListChanged(Object sender, ListChangedEventArgs e)
at System.Data.DataView.OnListChanged(ListChangedEventArgs e)
at System.Data.DataView.IndexListChanged(Object sender, ListChangedEventArgs e)
at System.Data.DataView.IndexListChangedInternal(ListChangedEventArgs e)
at System.Data.DataViewListener.IndexListChanged(ListChangedEventArgs e)
at System.Data.Index.<>c.b__88_0(DataViewListener listener, ListChangedEventArgs args, Boolean arg2, Boolean arg3)
at System.Data.Listeners1.Notify[T1,T2,T3](T1 arg1, T2 arg2, T3 arg3, Action
4 action)
at System.Data.Index.OnListChanged(ListChangedEventArgs e)
at System.Data.Index.OnListChanged(ListChangedType changedType, Int32 index)
at System.Data.Index.InsertRecord(Int32 record, Boolean fireEvent)
at System.Data.Index.ApplyChangeAction(Int32 record, Int32 action, Int32 changeRecord)
at System.Data.Index.RecordStateChanged(Int32 record, DataViewRowState oldState, DataViewRowState newState)
at System.Data.DataTable.RecordStateChanged(Int32 record1, DataViewRowState oldState1, DataViewRowState newState1, Int32 record2, DataViewRowState oldState2, DataViewRowState newState2)
at System.Data.DataTable.SetNewRecordWorker(DataRow row, Int32 proposedRecord, DataRowAction action, Boolean isInMerge, Boolean suppressEnsurePropertyChanged, Int32 position, Boolean fireEvent, Exception& deferredException)
at System.Data.DataTable.InsertRow(DataRow row, Int64 proposedID, Int32 pos, Boolean fireEvent)
at System.Data.DataRowCollection.Add(Object values)
at WindowsFormsApplication1.List.btnAdd_Click(Object sender, EventArgs e) in C:UsershamidiDocumentsVisual Studio 2010Projectsm_rezaeeWindowsFormsApplication1WindowsFormsApplication1List.cs:line 44
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.Run(Form mainForm)
at WindowsFormsApplication1.Program.Main() in C:UsershamidiDocumentsVisual Studio 2010Projectsm_rezaeeWindowsFormsApplication1WindowsFormsApplication1Program.cs:line 18
at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String args)
at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String args)
at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()
I couldn't find any clue about why it happens.
c# datatable system.data.sqlite indexoutofrangeexception
In the following code:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data.SQLite;
using System.Diagnostics;
namespace WindowsFormsApplication1
{
public partial class List : Form
{
public List()
{
InitializeComponent();
}
private void List_Load(object sender, EventArgs e)
{
comboBox1.SelectedIndex = 1;
}
private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
{
var cmd = new SQLiteCommand("select * from students", DB.Connection);
var ad = new SQLiteDataAdapter(cmd);
var dt = new DataTable();
ad.Fill(dt);
listBox1.DataSource = dt;
listBox1.DisplayMember = "name";
}
private void btnAdd_Click(object sender, EventArgs e)
{
Debug.Assert(listBox1.DataSource is DataTable);
var dt = listBox1.DataSource as DataTable;
dt.Rows.Add();
btnEdit.Enabled = btnRemove.Enabled = dt.Rows.Count != 0;
}
private void btnEdit_Click(object sender, EventArgs e)
{
Debug.Assert(listBox1.SelectedItem is DataRowView);
new StudentsForm2(listBox1.SelectedItem as DataRowView).ShowDialog(this);
}
private void btnRemove_Click(object sender, EventArgs e)
{
Debug.Assert(listBox1.DataSource is DataTable);
var dt = listBox1.DataSource as DataTable;
dt.Rows.RemoveAt(listBox1.SelectedIndex);
btnEdit.Enabled = btnRemove.Enabled = dt.Rows.Count != 0;
}
private void List_KeyDown(object sender, KeyEventArgs e)
{
if (e.KeyCode == Keys.Escape)
{
Close();
}
}
}
}
when the table is empty, I get the following exception:
A first chance exception of type 'System.ArgumentOutOfRangeException' occurred in System.Windows.Forms.dll
Additional information: InvalidArgument=Value of '0' is not valid for 'SelectedIndex'.
in method btnAdd_Click when it calls dt.Rows.Add(). comboBox1 holds tables names, but since I only have one table at the moment it's not used unless for comboBox1_SelectedIndexChanged to be called.
Here's the stack trace at the point the exception is thrown:
at System.Environment.GetStackTrace(Exception e, Boolean needFileInfo)
at System.Environment.get_StackTrace()
at System.Windows.Forms.ListBox.set_SelectedIndex(Int32 value)
at System.Windows.Forms.ListControl.DataManager_PositionChanged(Object sender, EventArgs e)
at System.Windows.Forms.CurrencyManager.OnPositionChanged(EventArgs e)
at System.Windows.Forms.CurrencyManager.ChangeRecordState(Int32 newPosition, Boolean validating, Boolean endCurrentEdit, Boolean firePositionChange, Boolean pullData)
at System.Windows.Forms.CurrencyManager.List_ListChanged(Object sender, ListChangedEventArgs e)
at System.Data.DataView.OnListChanged(ListChangedEventArgs e)
at System.Data.DataView.IndexListChanged(Object sender, ListChangedEventArgs e)
at System.Data.DataView.IndexListChangedInternal(ListChangedEventArgs e)
at System.Data.DataViewListener.IndexListChanged(ListChangedEventArgs e)
at System.Data.Index.<>c.b__88_0(DataViewListener listener, ListChangedEventArgs args, Boolean arg2, Boolean arg3)
at System.Data.Listeners1.Notify[T1,T2,T3](T1 arg1, T2 arg2, T3 arg3, Action
4 action)
at System.Data.Index.OnListChanged(ListChangedEventArgs e)
at System.Data.Index.OnListChanged(ListChangedType changedType, Int32 index)
at System.Data.Index.InsertRecord(Int32 record, Boolean fireEvent)
at System.Data.Index.ApplyChangeAction(Int32 record, Int32 action, Int32 changeRecord)
at System.Data.Index.RecordStateChanged(Int32 record, DataViewRowState oldState, DataViewRowState newState)
at System.Data.DataTable.RecordStateChanged(Int32 record1, DataViewRowState oldState1, DataViewRowState newState1, Int32 record2, DataViewRowState oldState2, DataViewRowState newState2)
at System.Data.DataTable.SetNewRecordWorker(DataRow row, Int32 proposedRecord, DataRowAction action, Boolean isInMerge, Boolean suppressEnsurePropertyChanged, Int32 position, Boolean fireEvent, Exception& deferredException)
at System.Data.DataTable.InsertRow(DataRow row, Int64 proposedID, Int32 pos, Boolean fireEvent)
at System.Data.DataRowCollection.Add(Object values)
at WindowsFormsApplication1.List.btnAdd_Click(Object sender, EventArgs e) in C:UsershamidiDocumentsVisual Studio 2010Projectsm_rezaeeWindowsFormsApplication1WindowsFormsApplication1List.cs:line 44
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.Run(Form mainForm)
at WindowsFormsApplication1.Program.Main() in C:UsershamidiDocumentsVisual Studio 2010Projectsm_rezaeeWindowsFormsApplication1WindowsFormsApplication1Program.cs:line 18
at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String args)
at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String args)
at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()
I couldn't find any clue about why it happens.
c# datatable system.data.sqlite indexoutofrangeexception
c# datatable system.data.sqlite indexoutofrangeexception
edited Nov 20 at 6:06
JohnB
1,3581015
1,3581015
asked Nov 20 at 5:20
hamidi
549616
549616
duplicate: stackoverflow.com/questions/5274357/…
– JohnB
Nov 20 at 5:32
add a comment |
duplicate: stackoverflow.com/questions/5274357/…
– JohnB
Nov 20 at 5:32
duplicate: stackoverflow.com/questions/5274357/…
– JohnB
Nov 20 at 5:32
duplicate: stackoverflow.com/questions/5274357/…
– JohnB
Nov 20 at 5:32
add a comment |
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53386665%2fan-unexcepted-exception-occurs-when-i-call-datarowcollection-add%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
duplicate: stackoverflow.com/questions/5274357/…
– JohnB
Nov 20 at 5:32