|
-
May 16th, 2008, 07:56 AM
#1
Problem with DataTable’s ‘Select’ method
I have a weird problem with the DataTable’s ‘Select’ method.
I use the ‘Select’ method throughout my application, and it works fine, but there is one occasion when it doesn’t work.
One of the columns in my DataTable is of type bool, named ‘X’.
At any point during the running of the application there is only one row at the most, that has this column set to true.
When I want to find out that row, I use the following statement:
Code:
DataRow[] rows = this.myDataSet.Tables["Item"].Select("[X] = 'true'");
if (rows.Length > 0)
{
// do something wirh rows[0]
}
This works fine, but there is one occasion that I spotted where the ‘Select’ doesn’t find any row, even though I know there’s one row (with ‘Id’ 123 for instance) having column ‘X’ set to true,
In order to make sure I’m not imagining things, I added the following line above:
Code:
DataRow[] tempRows = this.myDataSet.Tables["Item"].Select("[Id] = '123'");
I started debugging and stopped at the point in the application when I have this problem.
In the watch window, I saw the following:
tempRows[“Id”] = 123
tempRows[“X”] = true
rows.Length = 0
How is that possible?
Did anyone stumble upon this problem?
When I change a value of a row’s cell do I have to use the ‘AcceptChanges’ method?
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|