DataView Problem

C

Chuck Cobb

I have a table that has three rows in it.

Two were in the table originally and one was added.

I create a DataView on the table with no rowfilter and the RowStateFilter
set to CurrentRows and it only returns one row (not all three).

I checked the rowstate property of each row in the table and the rowstate of
each row is set to unchanged. Why won't the view return all three rows??

I'm puzzled by this...

Thanks,

Chuck Cobb
 
C

Chuck Cobb

This is getting even weirder... and its beginning to look like a Microsoft
bug.

I found that the number of rows in the view I was having problems with
changes and I have traced the change to a single line that creates an
instance of an XMLSerializer object.

Before I execute the instruction that creates a new instance of an
XMLSerializer object, the DataView returns the correct number of rows (3).
After I create the XML serializer object, the dataview returns only one row
(there are still three rows in the table).

How can that be??? How can creating an XMLSerializer object have anything
to do with creating a DataView? I think I somehow have a memory corruption
problem, but that's not supposed to happen with DotNet either...

Any ideas??
 
W

William Ryan eMVP

Hi Chuck:

This is intriguing indeed. What is it that you are serializing,
specifically what is the usage? Also, how are you checking the number of
rows? I dont' doubt that it may be a problem, I've just never seen anything
like this and would really like to figure it out. Another thing, if you
loop through the other rowstate options, how do they respond? For instance,
if you are doing the manual check and everything is unchanged, what happens
if you set the filter to unchanged? Do you have a bindingcontext or
something that's potentially editing the rows? That's about the only thing
I can think of that could conceivably cause this if it's not a bug.


Thanks,

Bill

www.devbuzz.com
www.knowdotnet.com
 
C

Chuck Cobb

Hello William,

I have definitely established that creating an XMLSerializer is causing this
problem - why that is happening is unclear because the XMLSerializer is not
touching the dataset the view is created from at all. It has to be some
kind of memory corruption problem.

I am serializing and deserializing some variables in XML that have nothing
directly to do with the dataset. (It is reading data stored in XML format
in a Visio VSD file and converting it from XML to a variable in memory) In
the following three lines of code, the second line that creates the
XMLSerializer is causing a problem. If I attempt to create a dataview on a
table in the dataset prior to the second line, I get three rows in the
dataview, if I do it immediately after the second line of code that creates
the new XMLSerializer, I get one row in the dataview: (Nothing has changed
in the dataset in between) This code is reading a list of attachments
stored in a Visio VSD file in XML format and putting the attachment list in
a variable called ShapeInfo.AttachmentInfo.
Dim ms As MemoryStream = MakeStream(XMLAttachmentList)
Dim s As New XmlSerializer(GetType(ShapeData.Attachments))
ShapeInfo.AttachmentInfo = CType(s.Deserialize(ms),
ShapeData.Attachments)

The dataset and the table I'm accessing in the dataset are not being touched
by the above code at all. The above code uses a memory stream which is
created by a routine called MakeStream which is shown below:
Friend Function MakeStream(ByVal InputString As String) As
MemoryStream

'***************************************************************************
*
' Makes a Memory Stream From a String

'***************************************************************************
*
Try
'----Create a Temporary Buffer to Hold Byte
Array----------------------------

Dim Buffer() As Byte
Dim ASCII As Encoding = Encoding.ASCII

'----Load Byte Array From
String---------------------------------------------
ReDim Buffer(InputString.Length + 1)
Buffer = ASCII.GetBytes(InputString.ToCharArray)

'----Return New Memory Stream Created from Byte
Array------------------------
Return New MemoryStream(Buffer)

Catch Exc As Exception
Throw New Exception("Error Atempting to Make a
Memory Stream", Exc)
End Try

End Function

Perhaps something in the above code is corrupting memory, but it has worked
reliably for a long time.

I have examined the rowstate of the three rows in the datatable I'm creating
the view from and they all show a rowstate of "Unchanged". I create the
view using the following code:

Dim dv As New DataView(DataSet1.Tables(TableName))

That code does not use a rowfilter or a rowstatefilter so it should select
all rows in the table. If I put a subroutine call to create the view prior
to creating the XMLSerializer and examine DV.Count I get three rows. If I
do the exact same thing after creating the XMLSerializer, I get one row.
Nothing in the dataset has changed in between and I've only executed one
instruction to create the XMLSerializer. This definitely looks like some
kind of memory corruption problem.

Thanks,

Chuck Cobb
 
W

William Ryan eMVP

Hi Chuck:

That sounds really strange indeed. Sounds like you did a really thorough
job tracking things down too. I guess the Rowstatefilter doesn't work with
any of the other rowstates either? I'm going to try to play with this and
see if I can recreate it, will let you know what I find out.

Bill


www.devbuzz.com
www.knowdotnet.com
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top