DefaultView.Count always returns 1

  • Thread starter Thread starter Daniel Walzenbach
  • Start date Start date
D

Daniel Walzenbach

Hi,



I have the following scenario:



myDataSet.Tables("tblCustomer").Rows.Count = 4



This is quite fine as the table contains 4 rows. However



myDataSet.Tables("tblCustomer").DefaultView.Count = 1



is not exactly what I expected it to be (I thought the result should be 4). Can anybody explain this behavior to me?



Thanks in advance



Daniel
 
Daniel,
I get the same count when using the following code:

' Note I create the sqlConnection1 and sqlDataAdapter1
' by dragging a Table from Server Explorer onto the WinForm.
Dim ds As DataSet = New DataSet
SqlDataAdapter1.Fill(ds, "customers")

MsgBox("Rows.Count = " & ds.Tables("customers").Rows.Count)
MsgBox("DefaultView.RowFilter = " & ds.Tables("customers").DefaultView.RowFilter)
MsgBox("DefaultView.RowStateFilter = " & ds.Tables("customers").DefaultView.RowStateFilter.ToString())
MsgBox("DefaultView.Count = " & ds.Tables("customers").DefaultView.Count)

--

Thanks,
Carl Prothman
Microsoft ASP.NET MVP
http://www.able-consulting.com
 
I'm going completely nuts. I have tried what you did and it works (don't
know if I should be :-) or :-(.). Now I have a form with nothing on it but
two stupid datagrids one bound to the dataset itself and the other one to
the dataview. My application on the other hand still doesn't work & I can't
see any mistake.



If anybody has ANY (really anything!!!) idea what my problem could be please
post it (Could it be a problem that my dataset was stored in a SessionID? Do
I loose any information doing so which I would need now?).



Thank you!



Daniel
 
Hi Carl,



I think I got it somehow to work. AFAIK by now I got my datasets somehow
messed up as I move them around between different asp.net pages.



Thank you!



Daniel.



P.S. It's difficult for me to post you some code as the .DefaultView method
works (as I told you) when used with a simple page. I would have to post you
the project and the related tables for you to reproduce my problem. Thanks
though for your offer!!




Carl Prothman said:
Daniel,
Please post some code that repros the problem.

--

Thanks,
Carl Prothman
Microsoft ASP.NET MVP
http://www.able-consulting.com


"Daniel Walzenbach" <[email protected]> wrote in
message news:[email protected]...
 
Back
Top