Hello,
I am looking for sample code if any, to save configuration XML file to database instead of saving to file.
Code Sample:
UltraTilePanel1.SaveAsXml("PanelFile.XML")
Is there any way I can save it directly to database?
Please let me know if you need more information.
Thanks
Imran
Thanks for your response and shared information with our community.
If you have any questions, feel free to write us.
Regards
Georgi,
While encoding Memory Stream to String( XML in String representation ) and loading back to XML I experienced following issue.
Detail:
Exception:
System.Xml.XMLException
Message : '.', hexadecimal value 0x00, is an invalid character. Line 47, position 1.
Resolution:
Used following blog and wrote equivalent VB.NET Code.
Reference:
http://social.msdn.microsoft.com/Forums/en-US/30d7cfd7-3de0-4082-930d-329b0265f174/solved-hexadecimal-value-0x00-is-an-invalid-character-xml
My VB.NET Equivalent Code:
Private Function NullRemover(ByVal bArray() As Byte) As Byte() Dim iv As Integer = 0 Dim temp() As Byte = New Byte(bArray.Length) {} For iv = 0 To bArray.Length - 1 Step 1 If bArray(iv) = &H0 Then Exit For End If temp(iv) = bArray(iv) Next Dim noNull() As Byte = New Byte(iv) {} For iv = 0 To noNull.Length - 1 Step 1 noNull(iv) = temp(iv) Next Return noNull End Function
Thanks,
Hello Imran
Imran Latif said:This approach to store XML to database is efficient ?
I`m not familiar with your final goals, so it is difficult for me to give an answer of your question, but the approach with XML in database has one big advantage and it is that, you are able to modify your XML on a database level. If you have such kind of intensions, then I think it is the right approach, otherwise you could use binary datatype
Let me know if you have any further questions.
Thanks for your help.
That works for me.
Now to Store XML Configuration I doing following.
Dim byteArray(5000) As Byte UltraTilePanel1.SaveAsXml(New MemoryStream(byteArray))
Dim strXML As String = System.Text.Encoding.Default.GetString(byteArray)
Then I store strXML to database to field as XML.
For Loading I am simply using
UltraTilePanel1.LoadXml(XML as String)
My concern:
To set memory limit of byteArray you should know XML File which you are going to store to database or some guess work.
Question:
This approach to store XML to database is efficient ?
Thanks for your quick response.
I will verify and update you with feedback soon.