Bug in FindRows

S

SevDer

Hi Guys,

I have the following issue on FindRows.

Below is my simple little method
--------------
public static DataRowView[] GetCountryDestinations(string
countryCode)
{
DataView filteredResults = Destionations.DefaultView;
filteredResults.Sort = "CountryCode";
return filteredResults.FindRows(countryCode);
}
--------------


As you see from this code, it always adds a sort in each call of the method,
however from time to time it throws the following exception and driving me
crazy

--------------
Find finds a row based on a Sort order, and no Sort order is specified.
--------------

Can someone tell me why?

SevDer
http://www.sevder.com
 
P

Peter Duniho

SevDer said:

If you post code that is actually the code that you are using, and it is
a complete-but-concise example of code that reliably reproduces the
problem, yes...it's likely someone can tell you why.

The code sample you offer isn't nearly enough to explain the behavior,
and it even has what appears to be a typographical error. Do you really
have a variable somewhere named "Destionations"?

Alternatively, you may find it useful to use the debugger to look at the
state of the DataView object at the time of the exception to confirm or
refute your assertion that it does in fact have a Sort order.

Also, you might want to try appending the text "ASC" or "DESC" to the
string containing the column name for the property to be valid.

For example:

filteredResults.Sort = "CountryCode ASC";

The docs claim that there is a default (ascending order), but given the
error you're getting, maybe they are wrong and at least in some cases it
has to be included explicitly.

Pete
 
S

SevDer

Hi Peter,

Thanks for the information.
Code is correct, but you are right, there is a type (no compilation errors
here).
However my problem is not always. Every once in a while this error is thrown
therefore my chances for debugger is really limited as I don't know when it
will happen.
Additionally

#region static members
public static DataTable Countries, Destionations, Zones;
#endregion

where this datatable is loaded in the static constructor.


By the way, I will still try your suggestion using "ASC" as a begining but I
still feel that there is a problem somewhere. (I hope my only problem is
ACS).
Thanks
SevDer
www.sevder.com

----------------------------------------------------------------------------------------------------------------------------------

Peter Duniho said:
SevDer said:

If you post code that is actually the code that you are using, and it is a
complete-but-concise example of code that reliably reproduces the problem,
yes...it's likely someone can tell you why.

The code sample you offer isn't nearly enough to explain the behavior, and
it even has what appears to be a typographical error. Do you really have
a variable somewhere named "Destionations"?

Alternatively, you may find it useful to use the debugger to look at the
state of the DataView object at the time of the exception to confirm or
refute your assertion that it does in fact have a Sort order.

Also, you might want to try appending the text "ASC" or "DESC" to the
string containing the column name for the property to be valid.

For example:

filteredResults.Sort = "CountryCode ASC";

The docs claim that there is a default (ascending order), but given the
error you're getting, maybe they are wrong and at least in some cases it
has to be included explicitly.

Pete
 
P

Peter Duniho

SevDer said:
Thanks for the information.
Code is correct, but you are right, there is a type (no compilation
errors here).

I would be surprised if it is true that _all_ of the code involved is
correct. Bugs in .NET are not unheard of, but your first suspicion
should be your own code, and only when you have absolutely ruled out any
possibility of a mistake should you consider that the bug may be in .NET.

As a first step, you really need to find a minimal amount of code that
can still reproduce the error. I suspect that you have something in
some other code that you haven't posted that is somehow interfering.
But since you haven't reduced your code to that minimal example, there's
no way for someone to help you find the error in your code.
However my problem is not always. Every once in a while this error is
thrown therefore my chances for debugger is really limited as I don't
know when it will happen.

Then you need to just keep testing it until you get the error. These
kinds of bugs are harder to debug, but they are not impossible. It just
takes some patience and some persistence.
Additionally

#region static members
public static DataTable Countries, Destionations, Zones;
#endregion

where this datatable is loaded in the static constructor.

I thought you said "Destionations" was a typo?

Pete
 
L

Linda Liu [MSFT]

Hi SevDer,

I performed a test based on your sample code but couldn't reproduce the
problem in my test.

It's hard to address this problem if I couldn't reproduce it. If possible,
could you please create a simple sample project that could just reproduce
the problem and send it to me?

To get my actual email address, remove 'online' from my displayed email
address.

Thank you for your understanding and cooperation!

Sincerely,
Linda Liu
Microsoft Online Community Support

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscriptions/support/default.aspx.
==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.
 
L

Linda Liu [MSFT]

Hi SevDer,

How about the problem now?

If the problem is still not solved, please feel free to let me know.

Thank you for using our MSDN Managed Newsgroup Suppor Service!

Sincerely,
Linda Liu
Microsoft Online Community Support
 
S

Steven Cheng[MSFT]

Hi SevDer,

Have you got any progress on this? If you would, please feel free to send a
simplified repro package to us so that we can help you do some further
research on this.

Looking forward to your response.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead


This posting is provided "AS IS" with no warranties, and confers no rights.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top