Don't think I can help here - Winforms is pretty much off my radar :-{
FWIW, I'd assume that the row is actuallly missing when you call the Serialize() but you coudl check just to narrow it down.
Also (completely left-field) you could try doing the EndEdits() before the AcceptChanges().......
>Hi Viv -
>
>Sorry I didn't reply to this sooner but that answer was, at the time, I don't know. i had run off in so many different directions chasing this that I wasn't sure which parts worked and which didn't.
>
>i think now the answer is that I have solved the serialization, which turned out to be easier than I was making it ( code below for lurkers ) and now have it reduced to a problem with Datagridviews using the dataset member as a datasource. (explained below and my current source of frustration)
>
>That first :
>
>I created a small test app with one table, three columns
>ikey int pk
>company varchar(100)
>wideobject varbinary(max)
>
>I have a dataset (Typedchildset) with two datatables ( Clients, Employees)
>
>I have 2 dgvs. For simplicity, I am binding them to the dataset member rather than using a binding source
>
>I enter data the two grids - Clients, then Employees.
>
>Everything saves when serialized as expected - except the last new row of the last grid.
>
>I can add five rows to employees and all save the last will be saved.
>
>NOTE : on further testing - the problem only comes about if the cursor is still in the newly added row when the save is called. If I first click out of the grid to another control, then save, the last row is saved. But of course, the use won't do that, so i must force something so the endedit actually ends the edit for that row.
>
>In the BeforeSave event of my business object :
>
>
>
>'Tried me.txtCompany.focus() before the code below, as actaully clicking the textbox to get out of the grid before clicking the Save button seems to work - no joy
>
>' I found I needed this before the endedits or I also lost the last new row of the first grid
>
> Me.TypedChildset1.AcceptChanges()
>
> Me.dgvClients.EndEdit()
> Me.dgvEmployees.EndEdit()
>
>'
>
>' Here's the serializer - works fine ( note : remotingformat prop of ds instance must be
>' set to binary
>
> '-- Copy dataset to property
>
> '-- Establish locals
> Dim loFormatter As New BinaryFormatter()
> Dim loStream As New System.IO.MemoryStream()
>
> '-- Serialize the business object
> loFormatter.Serialize(loStream, Me.TypedChildset1)
>
> '-- Return the created stream
> Me.CompaniesBO1.WideObject = loStream.ToArray()
>
>
>Feel I'm getting very very close, but this last bit is making me crazi(er).
>
>Thoughts?
>
>
>>Hi,
>>Did you solve this?,
>>Best,
>>Viv
>>
>>>I have a varchar(max) field in SQL 2008 Dataset_XML. My strongly typed business object is mapped to that column, and returns
>>>
>>><dsPolicies xmlns="http://tempuri.org/dsPolicies.xsd" />
>>>
>>>for a null. ( this is because I am adding this field to a current app an have to allow nulls, but I could script this as a value for all null values and then not allow nulls if that would help)
>>>
>>>dsPolicies is dropped on the form and the instance is names dsPolicies1.
>>>
>>>The dataset is typed with 8 tables. and the XSD file seems to be working as I am using bindingsources for each table and the datagridviews are showing the right columns.
>>>
>>>In the parentform_loading event of the business object on the Policies form I am trying to deserialize the XML stored in Me.PoliciesBO1.Dataset_XML ( which has the default value shown above) using this code :
>>>
>>>
>>> Private Sub PoliciesBO1_ParentFormLoading() Handles PoliciesBO1.ParentFormLoading
>>>
>>> Me.PoliciesBO1.fillall()
>>>
>>> If Me.PoliciesBO1.Count > 0 Then
>>>
>>> Me.DsPolicies1 = _ CType(InsurtecPW.Base.Utility.SmartDeSerialize(Me.PoliciesBO1.Dataset_XML), InsurtecPW.dsPolicies)
>>>
>>> End If
>>>
>>> End Sub
>>>
>>>
>>>and this is the deserialize routine :
>>>
>>> Public Shared Function SmartDeSerialize(ByVal serialized As String) As DataSet
>>> Dim __ds As DataSet = New DataSet
>>> ' needed to create an XML TextReader
>>> Dim nt As NameTable = New NameTable
>>> Dim nsmgr As XmlNamespaceManager = New XmlNamespaceManager(nt)
>>> Dim context As XmlParserContext = New XmlParserContext(Nothing, nsmgr, Nothing, XmlSpace.None)
>>> Dim tr As XmlTextReader = New XmlTextReader(serialized, XmlNodeType.Document, context)
>>> Try
>>>
>>> __ds.ReadXml(tr)
>>>
>>> Return __ds
>>> Finally
>>> If Not (tr Is Nothing) Then
>>> tr.Close()
>>> tr = Nothing
>>> End If
>>> context = Nothing
>>> nsmgr = Nothing
>>> nt = Nothing
>>>
>>> End Try
>>>
>>> End Function
>>>
>>>
>>>As you see, this returns a dataset, but I don't seem to be able to cast the return value as the dsPolicies that I need.
>>>
>>>Unable to cast object of type 'System.Data.DataSet' to type 'InsurtecPW.dsPolicies'.
>>>
>>>I have also tried a directcast of the returned dataset and got the same result.
>>>
>>>This approach seemed to work find when I was using an untyped dataset.
>>>
>>>I'd appreciate any thoughts on this. I'm pretty clueless about possible differences between the dataset class and a typed dataset or if my problem is the value I am returning if the column is empty.
>>>
>>>I am open to any approach (including serializing to a byte array) which will allow me to write and entire dataset to a sql column and bring it back.
>>>
>>>Suggestions very much appreciated.
>>>
>>>TIA