Re: NullReferenceExeption in DataTable
- From: Thomas W. Brown <thomas_w_brown@xxxxxxxxxxxxxxxxxxxxxx>
- Date: Thu, 17 Nov 2005 11:35:12 -0800
I am seeing the exact same thing (and a quick Google search turns up many,
many hits on this problem). Perhaps there is an update on the issue?
Here is my stack trace:
StackTrace " at System.Data.Select.FindClosestCandidateIndex()
at System.Data.Select.SelectRows()
at System.Data.DataTable.Select(String filterExpression)
at Pathfinder.Entity.FindRows(String query) in
C:\\Development\\05.11.01\\ClassLibrary\\ProfileManager\\Entity.cs:line 3428"
The code snippet is:
DataRow[] rows = new DataRow[0];
try
{
rows = ((DataTable)this).Select(query);
}
catch (Exception ex)
{
Console.WriteLine("Unable to perform DataTable.Select: {0}", ex.Message);
}
'this', is my DataTable derived object and is most definitely not null. It
has seven columns and *all* are in the PrimaryKey on the table. At the point
where the exception is being thrown there are only 33 rows in the table. The
query string is non null and valid (it is filtering on four of the seven PK
values). FWIW, the query string is:
"PkgProgId = 13 and SettlementDt > '2005/11/07' and IssueDt <= '2005/11/01'"
PkgProgId is an Int32
SettlementDt and IssueDt are (of course) DateTime
This exception does not always occur and I can perform thousands of these
Select operations against this table without problem. But once the exception
is thrown it will always be thrown.
I have seen speculation that it may be due to having one or more DataView
objects created for the table and that, somehow, this messes up the internal
indexing. I have not seen that this speculation has been confirmed and there
is nothing in the MSDN KB for this issue (that I was able to find).
Anyway, I was hoping that there would be more information on this subject,
and perhaps confirmation from MS that it is a problem and that there is
something that can be done as a work-around.
Regards,
-- Thomas Brown
"W.G. Ryan - MVP" wrote:
> Is calling .Select alone throwing the exception or are you setting some
> variable to the result? Actually, if you don't mind, can you post the code
> snippet and the piece that's throwing the exception?
> "Andreas Rossi" <Andreas Rossi@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
> news:8DDA30F8-B16C-49F7-A68F-28BA1AADCE2F@xxxxxxxxxxxxxxxx
> > Hello,
> >
> > we use a DataTable-Object to manage some data. Sometimes we get
> > NullReferenceExeptions when we call DataTable.Select or when we change a
> > row.
> > Below you can see the callstacks:
> >
> > CallStack: at System.Data.RecordManager.NewRecordBase()
> > at System.Data.DataTable.NewRecord(Int32 sourceRecord)
> > at System.Data.DataRow.BeginEdit()
> > at System.Data.DataRow.set_Item(DataColumn column, Object value)
> > at System.Data.DataRow.set_Item(String columnName, Object value)
> >
> > an other callstack:
> > CallStack: at System.Data.Select.FindClosestCandidateIndex()
> > at System.Data.Select.SelectRows()
> > at System.Data.DataTable.Select(String filterExpression)
> >
> > or the last callstack:
> > CallStack: at System.Data.DataTable.get_LiveIndexes()
> > at System.Data.DataTable.SetNewRecord(DataRow row, Int32 proposedRecord,
> > DataRowAction action, Boolean isInMerge)
> > at System.Data.DataRow.EndEdit()
> > at System.Data.DataRow.set_Item(DataColumn column, Object value)
> > at System.Data.DataRow.set_Item(String columnName, Object value)
> >
> > Does anyone know the reason for that exceptions?
> >
> > Thanks
> > Andreas
> >
>
>
>
.
- Prev by Date: Re: Alternative to using DSN to connect to database
- Next by Date: Re: Passing connection or dataset to a User Control
- Previous by thread: cannot connect to oracle with VS 2003 and oracle Plugin
- Next by thread: Re: ADO.NET 2.0 TransactionScope object question: across business obje
- Index(es):
Relevant Pages
|