This time round, I'm creating an XML file using the ADO.Recordset.Save command and am interested in querying back to the XML file to keep network traffic to and from the database to a minimum.
As of now, each time the mshflexgrid I'm using is sorted I have to requery in order to change the alias to include "\/" or "/\" to indicate how it's being sorted. And each time I requery, I'm having to connect back to the database and I'm wanting to keep the database queries only occuring during the search command and not the sorting.
I've arrived to the conclusion of needing to requery and use the alias as column headers because when I use the TextMatrix property to change the text, the text is only changing for a split second and returning to the recordset field names. I've also tried doing CellFontBold (original want), but that also would only change for a moment and return to default nonbold once the sorting had completed no matter how I called it (before or after sorting inside or outside that procedure).
I know it's possible to reopen the file using rs.open XMLFileName, but I need to change the field names --aliases (as mentioned above).
If it's possible to do this by saving the recordset in a ADTG file, then I'll go that route instead.
So far I'm creating a XML file:
How I'm setting the recordset to the flexgird with no problems:
As of now, each time the mshflexgrid I'm using is sorted I have to requery in order to change the alias to include "\/" or "/\" to indicate how it's being sorted. And each time I requery, I'm having to connect back to the database and I'm wanting to keep the database queries only occuring during the search command and not the sorting.
I've arrived to the conclusion of needing to requery and use the alias as column headers because when I use the TextMatrix property to change the text, the text is only changing for a split second and returning to the recordset field names. I've also tried doing CellFontBold (original want), but that also would only change for a moment and return to default nonbold once the sorting had completed no matter how I called it (before or after sorting inside or outside that procedure).
I know it's possible to reopen the file using rs.open XMLFileName, but I need to change the field names --aliases (as mentioned above).
If it's possible to do this by saving the recordset in a ADTG file, then I'll go that route instead.
So far I'm creating a XML file:
Code:
Private const sTempFile = "C:\Temp.xml"
Sub CreateXMLfile()
Dim rs as ADODB.Recordset
Dim rsConn As ADODB.Connection
Set rsConn = New ADODB.Connection
With rsConn
.ConnectionString = "DSN = Database"
.ConnectionTimeout = 60
.CommandTimeout = 20
.CursorLocation = adUseClient
.Mode = adModeRead + adModeShareDenyNone
.Open
End With
Set rs = New ADODB.Recordset
With rs
.ActiveConnection = rsConn
.Source = "Select [Something] from Table where [Something] = 'This'
.Open
End With
Set rs.ActiveConnection = Nothing
rsConn.Close
If Dir(sTempFile) <> "" Then Kill sTempFile
rs.Save sTempFile, adPersistXML
rs.Close
Set rsConn = Nothing
Set rs = Nothing
end sub
Code:
Private Sub SortColumns(ByVal Sort_Column As Integer)
'rsSearch is a module level ADODB.Recordset
'rsConn is a module level ADODB.Connection
Set rsConn = SetRSConn 'function that sets all the necessary parameters (those parameters are listed above)
rsSearch.Open sTemp, rsConn
Set rsSearch.ActiveConnection = Nothing
rsConn.Close
Set Me.MSHFlexGrid.Recordset = Nothing
Set Me.MSHFlexGrid.Recordset = rsSearch
rsSearch.Close
End Sub
Last edited: