As work requires, use ADO to query the database, and then serialize the query records to the memory and transmit them over the network to another machine for deserialization Into A recordset.
For more information, see ipersiststream, istream, olesavetostream, and oleloadfromstream. Well, it's good. The example provided by Ms passes the perfect test ~
The sky is unpredictable. Due to business needs, you must use the variable binding method in the query statement to query the database, instead of combining the query SQL statements. The advantage of this method is that, see here. Because of this requirement, you must use
Command object (the command object can only bind parameters ). For example, see here
However, after the command object executes the execute method, the returned result recordset cannot be serialized. In this case, the recordset object is read-only and cannot be modified. Therefore, an error ("query does not support interfaces") is returned when olesavetostream is called !! This dude is exactly the same as what I 've experienced.
If you are unwilling, you will not stop debugging (debugging and testing), but you will not stop Google
Finally, I found the solution. Because recordset supports open from command, and command is the only way to bind variables, the problem is finally solved by combining the open method of recorset.Code
_ Commandptr cmd; cmd. createinstance ("ADODB. command "); cmd-> activeconnection = pnode-> PCN; cmd-> commandtype = ad1_text; cmd-> commandtext = vssqltext; cstrarrayex spara; spara. splitword (vsparalist, "\ n"); // createparameter append... // append (CMD-> createparameter ("", addouble, adparaminput, 20, (_ variant_t) & spara. getword (I) [1]); _ variant_t affect; // _ recordsetptr PRS = cmd-> execute (& affect, 0, ad1_text); _ recordsetptr PRS; PRS. createinstance (_ uuidof (recordset); PRS-> cursorlocation = aduseclient; PRS-> cursortype = adopendynamic; PRS-> locktype = adlockbatchoptimistic; PRS-> open (idispatch *) CMD, vtmissing, adopenstatic, adlockbatchoptimistic,-1); istreamptr stream; stream. createinstance (_ uuidof (istream); STD: vector <char> Buf; If (savers (PRS, & stream) = s_ OK & streamtomem (stream, Buf ))
Now, we need to consider how to solve the serialization of datasets across platforms. How can this problem be solved? This is an issue worth consideration!