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

Discussion of open issues, suggestions and bugs regarding SDAC (SQL Server Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
alank2
Posts: 3
Joined: Mon 11 Aug 2008 17:28

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

Post by alank2 » Mon 11 Aug 2008 17:30

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

Dimon
Devart Team
Posts: 2888
Joined: Mon 05 Mar 2007 16:32

Post by Dimon » Mon 18 Aug 2008 12:29

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.

alank2
Posts: 3
Joined: Mon 11 Aug 2008 17:28

Post by alank2 » Tue 19 Aug 2008 16:01

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

Challenger
Devart Team
Posts: 925
Joined: Thu 17 Nov 2005 10:53

Post by Challenger » Wed 20 Aug 2008 12:13

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

alank2
Posts: 3
Joined: Mon 11 Aug 2008 17:28

Post by alank2 » Fri 22 Aug 2008 12:27

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

Post Reply