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??

Re: Why does my Dataview NOT work!!! by William

William
Tue Jun 01 21:02:59 CDT 2004

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??
>
>



Re: Why does my Dataview NOT work!!! by Scott

Scott
Tue Jun 01 21:07:59 CDT 2004

Private Sub MakeDataView()
Dim dv As New DataView
With dv
.Table = vdsVehicle.Tables(0)
.AllowDelete = True
.AllowEdit = True
.AllowNew = True
.RowFilter = "VehicleYear = '1985'"
.RowStateFilter = DataViewRowState.ModifiedCurrent
.Sort = "someField"
End With
End Sub

"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??
>
>



Re: Why does my Dataview NOT work!!! by Aaron

Aaron
Tue Jun 01 21:14:09 CDT 2004

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??
> >
> >
>
>



Re: Why does my Dataview NOT work!!! by William

William
Tue Jun 01 21:26:11 CDT 2004

I used your exact code. But I put 5 entries in my dummy table... If I do
dt.Rows.Count I get 5. if I do dv.Count I get 1. If I have a grid, and
it's bound to my dataview, it shows one record, if it's bound to the table i
have 5 records in it. So I was asking how you determined that you had 3
records vs 1.

--
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??
> > >
> > >
> >
> >
>
>



Re: Why does my Dataview NOT work!!! by Aaron

Aaron
Tue Jun 01 21:34:22 CDT 2004

Nope.

when I do: ?dv.Table.Rows.Count I get 3 rows when I should be getting 1
row.



"Scott M." <s-mar@nospam.nospam> wrote in message
news:euWCgZESEHA.1396@TK2MSFTNGP12.phx.gbl...
> Private Sub MakeDataView()
> Dim dv As New DataView
> With dv
> .Table = vdsVehicle.Tables(0)
> .AllowDelete = True
> .AllowEdit = True
> .AllowNew = True
> .RowFilter = "VehicleYear = '1985'"
> .RowStateFilter = DataViewRowState.ModifiedCurrent
> .Sort = "someField"
> End With
> End Sub
>
> "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??
> >
> >
>
>



Re: Why does my Dataview NOT work!!! by William

William
Tue Jun 01 21:50:45 CDT 2004

Because the Table still has 3 rows in it. That's what I was referring to
above. Scott's code is identical to yours in and should yeild no difference
b/c the properties that are set are merely the default values or are
unrelated to count.

Try dv.Count and you should see 1. I used your code and got 1 in the first
test. Then I redid it with another table I created, did it in C# just to
show it's not the language or anything like that. The results are correct.

dv.Table.Rows.Count is going to be 3 b/c if you do dv.Table.TableName you'll
see it's dt. The rowfilter only affects the view. If you do dv.Count
you'll see it's one. I posted another snippet of my second attempt, this
time with 2 records at 1985. Works exactly as expected.

I think you're fine, it's like I said in the first post, your measurement of
Rows is the problem.

HTH,

Bill

--
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:eJKUeoESEHA.2332@TK2MSFTNGP10.phx.gbl...
> Nope.
>
> when I do: ?dv.Table.Rows.Count I get 3 rows when I should be getting 1
> row.
>
>
>
> "Scott M." <s-mar@nospam.nospam> wrote in message
> news:euWCgZESEHA.1396@TK2MSFTNGP12.phx.gbl...
> > Private Sub MakeDataView()
> > Dim dv As New DataView
> > With dv
> > .Table = vdsVehicle.Tables(0)
> > .AllowDelete = True
> > .AllowEdit = True
> > .AllowNew = True
> > .RowFilter = "VehicleYear = '1985'"
> > .RowStateFilter = DataViewRowState.ModifiedCurrent
> > .Sort = "someField"
> > End With
> > End Sub
> >
> > "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??
> > >
> > >
> >
> >
>
>



Re: Why does my Dataview NOT work!!! by William

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??
> > >
> > >
> >
> >
>
>