How to assign OleVariant to a TDataSet

lwkenneth2 used Ask the Experts™
I write a function in Server side which will pass a OleVariant which is exported from a TADOQuery.  Can I Load the oleVariant back to a TADOQuery or other other dataset that I can operate in Client Side?
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Top Expert 2011

You can just cast the OleVariant back to the original type when assigning it at the Client side.
Emmanuel PASQUIERFreelance Project Manager
Top Expert 2010

1) What Server / Client side are you referring to ?
2) What do you mean by export an TADOQuery to an OleVariant ?
3) What do you mean by loading the OleVariant back to another dataset ?
4) Then, that is maybe redundancy with 1st question, how does that OleVariant get transfered from *server* to *client* ?

JimyX, do you care explaining a bit more, with a code sample ? I'm sorry , but if I couldn't see it, I would not believe that your answer can be as cryptic as the question. Yet it is and you are a Sage... Or am I missing something so implicitly evident there ?
Software Engineer

First, you can not type cast OleVariant to a TDataset

Here is the simplest way to do it. Use TClientDataset with your TADOQuery as the provider. TClientDataset has a property called Data (TClientDataset.Data) which is OleVariant

   MyData: OLEVariant;
   MyData := ClientDataset1.Data;  this will put the data into MyData as OleVariant

When reading the data it is again quite as simple

  ClientDataset1.Data := MyData;

//To get data from TADOQuery itself as OLEVariant is not very simple, you would have to thoroughly understand the _Recordset object and how the data is stored

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial