William
Tue Jun 01 21:51:52 CDT 2004
Make sure you are checking dv.Count not the count of the rows in the table.
They aren't the same if you set a rowfilter that filters anything out.
Here's the code recreated in C#. I used a new table and everything. I
already did it with your code and verified that it's the way you are
counting rows, but if you follow my comments, it should clear it up. Note
that this pass I have 2 rows with 1985.
private void button6_Click(object sender, System.EventArgs e)
{
//Created a Table "TestTable" in NorthWind
//With 5 records total. Two Columns, VehicleYear
//and IDCode - IDCode does nothing but serve
//as a dummy Key so I can add multiple years to test this
//properly. Two instances of 1985 are currently in the db
//As expected, after applying the filter, 2 records exist
//in the DataView (dv), 5 in the DataTable (dt or
dsTest.Tables[0]
DataSet dsTest = new DataSet();
sqlDataAdapter4.Fill(dsTest, "TestTable");
DataTable dt = dsTest.Tables[0];
DataView dv = dt.DefaultView;
MessageBox.Show(dt.Rows.Count.ToString());//5
dv.RowFilter = "VehicleYear = '1985'";
MessageBox.Show(dv.Count.ToString()); //2
}
--
W.G. Ryan MVP Windows - Embedded
http://forums.devbuzz.com
http://www.knowdotnet.com/dataaccess.html
http://www.msmvps.com/williamryan/
"Aaron Ackerman" <none@nospam.com> wrote in message
news:O4WpLdESEHA.2976@TK2MSFTNGP10.phx.gbl...
> I'm not following, I am passing my DataTable to the DataView then doing my
> filter.
> Can you post code that shows how to do it correctly??
>
>
>
>
> "William Ryan eMVP" <dotnetguru@comcast.nospam.net> wrote in message
> news:e3ES0WESEHA.2332@TK2MSFTNGP10.phx.gbl...
> > The DataSet can't have rows, only DataTables can but how are you
verifying
> > the rows with the dataview? I've just built an app with 1985 and I'm
not
> > having an issue.
> >
> > --
> > W.G. Ryan MVP Windows - Embedded
> >
> >
http://forums.devbuzz.com
> >
http://www.knowdotnet.com/dataaccess.html
> >
http://www.msmvps.com/williamryan/
> > "Aaron Ackerman" <none@nospam.com> wrote in message
> > news:%23w%23DIxDSEHA.1340@TK2MSFTNGP12.phx.gbl...
> > > Me.SqlDataAdapter1.Fill(Me.vdsVehicle)
> > >
> > > Dim dt As New DataTable
> > > dt = Me.vdsVehicle.Tables(0)
> > >
> > > Dim dv As New DataView(dt)
> > > dv.RowFilter = "VehicleYear = '1985'"
> > >
> > >
> > > both the Dataset and the Dataview still have three records. It is not
> > > filtered down to ONE record like it should be. Why??
> > >
> > >
> >
> >
>
>