I have a column in a DataView that contains NaN. When I attempt to Sort on
this column, I get:
MESSAGE: Index was outside the bounds of the array.
SOURCE: System.Data
STACKTRACE:
at System.Data.Ind ex.Sort(Int32 left, Int32 right)
at System.Data.Ind ex.InitRecords( )
at System.Data.Ind ex..ctor(DataTa ble table, Int32[] indexDesc,
DataViewRowStat e recordStates, IFilter rowFilter)
at System.Data.Dat aTable.GetIndex (Int32[] indexDesc, DataViewRowStat e
recordStates, IFilter rowFilter)
at System.Data.Dat aTable.GetIndex (String sort, DataViewRowStat e
recordStates, IFilter rowFilter)
at System.Data.Dat aView.UpdateInd ex(Boolean force)
at System.Data.Dat aView.SetIndex( String newSort, DataViewRowStat e
newRowStates, DataFilter newRowFilter)
at System.Data.Dat aView.set_Sort( String value)
Here is my repro code:
public static void sortDataView()
{
DataTable dt = new DataTable();
dt.Columns.Add( new DataColumn("bar ",Type.GetType( "System.Double" )));
dt.Columns.Add( new DataColumn("foo ",Type.GetType( "System.Double" ),
"bar / 0"));
dt.Rows.Add(new Object[]{0});
dt.Rows.Add(new Object[]{0});
dt.DefaultView. Sort = "foo ASC"; // <-- This Line Errors!
}
However, if I debug with VS.NET 2003 and break just before the sort command
and run it in the Command Window, then continue, there is no error. I just
copied the line from the source that errors into the Command Window and it
executes just fine. I continue and my app runs without errors.
How do I fix this? (Besides fixing my divide by zero error)
thanks
-ivan. 3 4489
Well I don't know if this helps too much, or if i'm just saying
something obvious, but NaN represents Not a Number, so it looks like it
is trying to sort with an invalid value in there.
isn't foo null....aren't you adding a (new Object[]{0}) which goes into
bar.
so that makes foo null and not a double.
"INeedADip" <in*******@gmai l.com> wrote in news:1142646485 .717703.265910
@j33g2000cwa.go oglegroups.com: isn't foo null....aren't you adding a (new Object[]{0}) which goes into bar. so that makes foo null and not a double.
No, foo is a computed column:
new DataColumn("foo ",Type.GetType( "System.Double" ),"bar / 0");
So foo contains bar / 0, which is, of course, always NaN.
The interesting thing is I can Sort a DataView with just one NaN value in
the sort column without error. If there are two or more NaN values in the
sort column, I get the error when I sort.
-ivan. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: jwedel_stolo |
last post by:
Hi
I'm creating a dataview "on the fly" in order to sort some data prior to writing out the information to a MS SQL table
I have used two methods in order to determine the sort order of the DataView. (I'm writing in C# with the v1.1.4322 of the .NET Framework, in Window2K server"). First of all, here are the two methods I have used in order to...
|
by: Raymond Lewallen |
last post by:
I have a dataview in which the sort property will not sort the dataview.
Here's is a simple scenario similar to what I am doing:
Class Foo
Private Function Retrieve() As DataView
' Returns a DataView with 2 columns and 3 rows
Dim ADOHelper As New DAL.ADOHelper
Return ADOHelper.GetMyDataview()
End
|
by: Jason |
last post by:
Is it possible to somehow sort a dataview, all on one column, but on
different variables?
That is, I have a 'Title' column in my dataview and I'd like to display
first all "Directors" (sorted), then everyone else (sorted). I've used the
'ItemBound' but can't figure out how to do this with that procedure.
Thanks in advance, any ideas are...
|
by: troyblakely |
last post by:
I am having trouble sorting a datagrid. I have read numerous posts on
this and other lists, and tried most of the suggestions, but none of
them have worked for me yet. I populate a dataset from two queries,
then I want to sort the data and bind it to a datagrid. Regardless of
what I have tried, the datagrid is populated with the unsorted data....
|
by: David Wender |
last post by:
I want to create a dataview with a sort on multiple columns. However,
when I use FindRows, I only want to search some of the columns, not
all. Is this possible? I have not been able to make it happen.
Dim objKeys(2) as Object
objKeys(0) = "CL"
objKeys(2) = 4000
Dim posView As DataView = New DataView(posDS.Tables("Positions"), _
| |
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it. ...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert...
| |
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |