Hi
I am working on a .NET 2.0 application using UltraWingrid.
I am saving the layout of the grid as follows.
Private GridLayoutsTable As New DataTable
Dim MS As New IO.MemoryStream() Me.grdData.DisplayLayout.Save(MS, Infragistics.Win.UltraWinGrid.PropertyCategories.All)
Dim LayoutArray() As Byte LayoutArray = MS.ToArray()
GridLayoutsTable.Rows.Add(New Object() {Nothing, "MyGridLayout", LayoutArray})
I am getting an error as "Input array is longer than the number of columns in this table."
How to Save the layout values to Database and Load it again?
Thanks
Ashok
I don't see why it's taking a long time to store or retrieve this file, and if the bottleneck is coming from your server and not the form, there's not really any suggestions that I can make since it's a DB issue. You can use the Save/Load methods on the DisplayLayout, which save this information in binary format and should make the file size smaller. Also, since you're using SQL 2005, try varbinary(MAX) instead.
-Matt
I am saving the Displaylayout XML string in a table in Sql server 2005 database. I have kept the column type as Varchar (MAX).
It is taking very long time to fetch that XML string from the table when i use Select query to fetch that XML string from DB.
How XML string can stored and retrieved faster?
Is it possible to store the XML file in some other format ? (like BinaryFormat)
I am binding the DisplayLayout XML in the form load. It is taking a long time to load the form because of this problem.
How Display layout can be stored and retrieved faster?
You're getting an error regarding it not being in a binary format because you're using the SaveAsXml method but then trying to load it with the binary load method. Use LoadFromXml instead.
Hi Andy Jones
Thanks for your reply .I have the above code and saved the XML file in the database. I am not able to convert the XML into stream and call DisplayLayout.Load method.
Dim LayoutXML As String = ""
Dim myEncoder As New System.Text.ASCIIEncoding
Dim ms1 As IO.MemoryStream = New IO.MemoryStream(bytes)
Me.grdData.DisplayLayout.Load(CType(ms1, IO.Stream), PropertyCategories.All) --- Gives Error in this line
I am getting the following exception in the above line.
System.Runtime.Serialization.SerializationException = {"The input stream is not a valid binary format. The starting contents (in bytes) are: 3C-53-4F-41-50-2D-45-4E-56-3A-45-6E-76-65-6C-6F-70 ..."}
How convert the XML into Stream and call DisplayLayout.Load method.?
The specific error you are getting is purely to do with the fact you are passing in three values into a table that contains less than three columns. It is not reporting that the Byte Array is too large.
Would it be possible to use the SaveToXml method of DisplayLayout instead? That way you can easily store the XML string in the database.
Something like this should do it:
Dim GridLayoutsTable As New DataTable
' Create the DataTable to store the serialized layout.
Dim column As DataColumn
column = New DataColumn("ID", GetType(Integer))
column.AutoIncrement = True
GridLayoutsTable.Columns.Add(column)
column = New DataColumn("Name", GetType(String))
column = New DataColumn("LayoutXML", GetType(String))
Using ms As New IO.MemoryStream()
' Read the serialized layout to a MemoryStream.
UltraGrid1.DisplayLayout.SaveAsXml(ms, Infragistics.Win.UltraWinGrid.PropertyCategories.All)
Using sr As IO.StreamReader = New IO.StreamReader(ms)
' Read the XML from the Stream into a String.
ms.Seek(0, IO.SeekOrigin.Begin)
Dim layout As String = sr.ReadToEnd()
' Store the layout in the table.
GridLayoutsTable.Rows.Add(New Object() {Nothing, "MyGridLayout", layout})
End Using