I'll attempt to answer your question, but if it were me, I think I would re-design this solution. Do you really need to store the letter in the database ? Maybe create a template letter, give it a unique document ID, then you could store multiple records with the student ID, template ID and sequence number. To answer your question ... Create a class and call it LetterDetail; at a minimum it would have a string to store the letter. Create another class and call it MailedLetters; this would contain a List(Of LetterDetail) The second class gives you the ability to have as many letters as you want grouped together. Within the second class, you would need 2 methods, Save and Load. This would serialize the object to an XML string which you could then save in the database. I'll give you some rough code for serialization ...
Public Shared Function Load(sFname As String) As MailedLetters
Dim xr As XmlReader
Dim settings As XmlWriterSettings = New XmlWriterSettings()
settings.Indent = True
settings.IndentChars = (ControlChars.Tab)
settings.OmitXmlDeclaration = True
Dim obj As New MailedLetters
Dim mySerializer As New XmlSerializer(obj.GetType)
xr = XmlReader.Create(sFname)
obj = mySerializer.Deserialize(xr)
xr.Close()
xr = Nothing
Return obj
End Function
Instead of serializing to a file, you want to serialize it to a string.
Sub Save(sFname As String)
Dim xw As XmlWriter
Dim mySerializer As New XmlSerializer(Me.GetType)
Dim settings As XmlWriterSettings = New XmlWriterSettings()
settings.Indent = True
settings.IndentChars = (ControlChars.Tab)
settings.OmitXmlDeclaration = False
xw = XmlWriter.Create(sFname, settings)
mySerializer.Serialize(xw, Me)
xw.Close()
End Sub
That's the best I can do for you, hope it helps. :java: