HomeActive Query BuilderHow I can save a query in XML? and , How I can load this query from XML?

How I can save a query in XML? and , How I can load this query from XML?


I need to save the height, the width and the positions of the tables within the Diagram Pane.

I tried the following:

Public Sub QuerySaveXML()
Dim doc As XmlDocument
Dim newElem As XmlElement
Try
doc = New XmlDocument()
newElem = doc.CreateElement("Query")
doc.AppendChild(newElem)
Dim wbxmldecl As XmlDeclaration
wbxmldecl = doc.CreateXmlDeclaration("1.0", "UTF-8", "yes")
doc.InsertBefore(wbxmldecl, newElem)
Me.QueryBuilder1.Query.SaveLayout(doc, newElem)
doc.Save("c:\data.xml")
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try
End Sub

This function creates a file to me like the following one
I believe that there are problems when I writing xml code in my request.

I go it to write without some signs

Query
SubQuery SQL='Select Customers.CustomerID, Customers.CompanyName, Customers.ContactName, Customers.ContactTitle, Customers.Address From Customers'
UnionSubQuery
DataSource SQL='Customers' X='245' Y='15' Height='199' Width='113'
UnionSubQuery
SubQuery
Query



I try to load my query of the file created with the following function:

Public Sub QueryLoadXML()
Dim doc As XmlDocument = New XmlDocument()
Dim newElem As XmlElement
Try
doc.Load("c:\data.xml")
newElem = doc.DocumentElement
Me.QueryBuilder1.Query.LoadLayout(newElem)
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try
End Sub

It is not working,Can you help me?

Thanks you
Bernardino Jaramillo | email
July 24 2007, 07:17 PM
To save/restore query in XML you have to use the QueryBuilder.LayoutSQL property.

Dim layout As String = queryBuilder1.LayoutSQL
...
queryBuilder1.LayoutSQL = layout
Eugeny Starkov | email
5 days, 10 hours since original post
This topic is closed