Page 1 of 1

Is there a way to save a MSQuery to a memory structure?

Posted: Mon 11 Aug 2008 17:30
by alank2
Hi,

I have two pieces of code that talk to each other over IP. One of them puts a request in, then the other gets the request, processes a SQL command and the result is contained in an MSQuery. Is there method in MSQuery that saves its state to a memory block so I can transfer than back to the source program so it can restore the memory block to a MSQuery and then mine the results?

I don't want the source program issuing the SQL commands directly...

Thanks,

Alan

Posted: Mon 18 Aug 2008 12:29
by Dimon
You can save recordset in memory using the TMSQuery.SaveToXML method.
To restore saved data in dataset you should use the TVirtualTable component and load data with the help of TVirtualTable.LoadFromStream or LoadFromFile functions.
You can find more detailed information about these methods in the SDAC help.

Posted: Tue 19 Aug 2008 16:01
by alank2
Hi,

Ok, I got that working. A 9000 record table takes a bit of time however to savetoxml and reload into a virtualtable. It takes about 6 seconds to save to a XML stream and 5.7 seconds to load from an XML stream.

IF I copy the data into a VirtualTable and use the SaveToStream which looks like some sort of binary stream, it only takes 0.3 seconds to savetostream and 0.891 seconds to loadfromstream. Considerably faster, but the problem is that the virtualtable.assign(msquery) command takes 17 seconds. Is there a way to make msquery save to the binary format? I don't see a savetostream method. Or, is there a way to execute a query and have the results dumped directly into the virtualtable?

Thanks,

Alan

Posted: Wed 20 Aug 2008 12:13
by Challenger
TMSQuery has no such functionality. We have added some optimization to the TVirtualTable.Assign method. This optimization will be available in the next build of SDAC. We are planning to release it this week

Posted: Fri 22 Aug 2008 12:27
by alank2
Good job Devart!!!!!!!!!

I just tested the 4.50.0.37 version a few minutes ago and it has a huge improvement in the tvirtualtable.assign method.

Old version = > 17 seconds, new version = 1.328 seconds!!

Thank you,

Alan