DataTable.Rows.Add exception NullReferenceException

  • Thread starter Thread starter AnthoneyR
  • Start date Start date
A

AnthoneyR

The following code causes a NullReferenceException
BUT, it does not happen on the developement machine, and it only
happens on another machine after the 2nd or 3rd time the code is
executed. The other machine has identical installations of the
framework and operating system (XP).

I have searched and tried various solutions. The moTimeTable does not
contain contraints, relationships, dataview filters or column
expressions. It does have an associated dataview and grid. Can anyone
shed some light on this? Any suggestions?

CODE>>
loRow = moTimeTable.NewRow()
loRow("chargecode") = loTaskRow(0)("chargecode")
loRow("descr") = loTaskRow(0)("name")
moTimeTable.Rows.Add(loRow) << Fails Here

EXCEPTION>>
System.NullReferenceException: Object reference not set to an instance
of an object.
at System.Data.DataTable.InsertRow(DataRow row, Int32 proposedID,
Int32 pos)
at System.Data.DataRowCollection.Add(DataRow row)
at TimeTrackerApp.usrWeekTotals.AddChargeRow(Int32 aTaskID)
at TimeTrackerApp.usrWeekTotals.LoadGrid()
at TimeTrackerApp.usrWeekViewer.cmbWeek_SelectedIndexChanged(Object
sender, EventArgs e)
at System.Windows.Forms.ComboBox.OnSelectedIndexChanged(EventArgs
e)
at System.Windows.Forms.ComboBox.set_SelectedIndex(Int32 value)
at TimeTrackerApp.usrWeekViewer.GoPrevWeek()
at TimeTrackerApp.usrWeekViewer.picPrev_Click(Object sender,
EventArgs e)
at System.Windows.Forms.Control.OnClick(EventArgs e)
at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons
button, Int32 clicks)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32
msg, IntPtr wparam, IntPtr lparam)

Running XP, Framework 1.1
 
Back
Top