Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / ADO.NET / June 2004

Tip: Looking for answers? Try searching our database.

Problems with DataView.RowFilter

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Jack - 29 Jun 2004 18:56 GMT
I have a DataView set up as following:

DataView dv = new DataView();
dv.Table = twsDS1.twsContractHdr;
dv.RowFilter = "AgencyID = '" + agency + "' AND NeedsStatus = 'I'";
int cnt = dv.Count;

In my test, this returns the expected value of "3" for the cnt of incomplete
items within the contract header table in the testdriver. If I then modify
one of the row needs status to "C" (completed) in the testdriver and rerun
the above, I expect to see "2" for this value... but it is still returning
the original value of 3.

I tried modifying to use a DataRow[] and foreach loop using a Select clause
using the same filter as above. It, too, loops three times after modifying a
row to "C". Displaying the text on each loop shows two are still "I" as
expected and the third "C" as NOT EXPECTED in that it should have been
filtered out in the Select.

What gives? Do I need to do an AcceptChanges?
William Ryan eMVP - 29 Jun 2004 19:42 GMT
Jack, check the value of NeedsStatus in the dattable, it sounds like the
edit isn't finished.  I don't think AcceptChanges is what you want b/c
you'll lose all of your edits so if you call update afterward you won't have
anything sent back to the db.  Are you rerunning the thing altogether or do
you have another function, it'd help if you could show how you were doing
the test.

Signature

W.G. Ryan, eMVP

Have an opinion on the effectiveness of Microsoft Embedded newsgroups?
Let Microsoft know!
https://www.windowsembeddedeval.com/community/newsgroups

> I have a DataView set up as following:
>
[quoted text clipped - 16 lines]
>
> What gives? Do I need to do an AcceptChanges?
Jack - 29 Jun 2004 21:31 GMT
> it'd help if you could show how you were doing
> the test.

The following code fragments, with the exception of using a DataRow array
rather than the DataView (result is the same for both) is what I am using.
The btnParcelComplete event sets Current, Prior, and Remption needs status.
If there are no further needs, the entire taxid is flagged as "C" (lhdr is a
DataRow in the twsDS1.twsContractHdr table). The test DataSet initially has
three "I" rows and the count in NoIncompleteTaxIds is accurate. When the btn
is clicked and the conditions meat in MofifyNeeds to reset one of the "I"
rows to "C", the count in NoIncompleteTaxIds should be reduced by 1 (i.e.,
2). Instead, cnt is STILL showing as 3 when lhdr.Cells["NeedsStatus"].Value
= "C" is met. The foreach loop shows two "I" and one "C"... so count should
have been 2 because "C" does not meet the Select criteria.

Code fragments are as follows:

private void btnParcelComplete_Click(object sender, System.EventArgs e)
{
   [...]
   ModifyNeeds();
}

private void ModifyNeeds()
{
   [...]
   if (   txtSCurrNeeds.Text      != "Y" &&
           txtSPriorNeeds.Text     != "Y" &&
           txtMRedemNeeds.Text != "Y" )
   {
       lhdr.Cells["Redemption"].Value = "*";
       lhdr.Cells["NeedsStatus"].Value = "C";
   }
   NoIncompleteTaxIds();
}

private bool NoIncompleteTaxIds()
{
   string agency = r.AgencyID;

   DataRow[] tstRows = twsDS1.twsContractHdr.Select("AgencyID = '" + agency
+ "' AND NeedsStatus = 'I'");
   int cnt = tstRows.Length;

   foreach (DataRow tst in tstRows)
   {
       string taxid = tst["TaxId"].ToString();
       string status = tst["NeedsStatus"].ToString();
   }

   txtMIncompleteCnt.Text = cnt.ToString();

   if (cnt > 0)
       return false;
   else
       return true;
}
William Ryan  eMVP - 29 Jun 2004 22:53 GMT
Is lhdr a Grid?  If so, then call .EndEdit.  You can verify that it's still
in edit mode by testing for HasChanges...
debug.Assert(mydataSet.HasChanges);
I'm guessing it's comign back as false.

Let me know if not.

Signature

W.G. Ryan MVP Windows - Embedded

http://forums.devbuzz.com
http://www.knowdotnet.com/dataaccess.html
http://www.msmvps.com/williamryan/

> > it'd help if you could show how you were doing
> > the test.
[quoted text clipped - 53 lines]
>         return true;
> }
Jack - 29 Jun 2004 23:22 GMT
> Is lhdr a Grid?  If so, then call .EndEdit.  You can verify that it's still
> in edit mode by testing for HasChanges...
> debug.Assert(mydataSet.HasChanges);
> I'm guessing it's comign back as false.

It's bound to an Infragistics UltraWinGrid... and calling ExitEditMode and
UpdateData on it doesn't seem to make a difference.

What is confusing is the DataTable row column IS showing the expected value
("C") in the test loop so the bound data is being propgated to the
underlying DataSet, it's just not filtering correctly in the Select (It
shouldn't be showing up at all.).
Jack - 30 Jun 2004 14:50 GMT
Never mind... found the problem. Forgot to do call the UpdateData method on
the grid.

Still curious as to why it was showing up as modified in the foreach loop
though. Must be some state nuance in the DataSet table that I don't
understand.

> > Is lhdr a Grid?  If so, then call .EndEdit.  You can verify that it's
> still
[quoted text clipped - 9 lines]
> underlying DataSet, it's just not filtering correctly in the Select (It
> shouldn't be showing up at all.).

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.