* Make sure you've added the following to ado.h to use ADO.Streams * #define adExecuteStream 0x400 #INCLUDE ado.h *-- Initialize vars LOCAL ; oADOConn AS ADODB.Connection, ; oADOCmd AS ADODB.Command, ; strmXMLOut AS ADODB.Stream, ; strmXMLIn AS ADODB.Stream, ; strXML AS String *-- Create connection oADOConn = CREATEOBJECT("ADODB.Connection") oADOConn.Mode = 3 oADOConn.ConnectionString = 'Provider=SQLOLEDB.1;' ; + 'Persist Security Info=False;' ; + 'Integrated Security=SSPI;' ; + 'Initial Catalog=Northwind;' ; + 'Data Source=(local)' *-- Create command object oADOCmd = CREATEOBJECT("ADODB.Command") *-- Open the connection oADOConn.Open *-- Set connection oADOCmd.ActiveConnection = oADOConn *-- Set output to receive XML stream strXML = "" strmXMLOut = CREATEOBJECT("ADODB.Stream") strmXMLIn = CREATEOBJECT("ADODB.Stream") oADOCmd.Properties("Output Stream") = strmXMLOut oADOCmd.Properties("Output Encoding") = "UTF-8" oADOCmd.CommandText = "SELECT * FROM employees FOR XML AUTO, BINARY BASE64" *-- Get the XML stream strmXMLOut.Open oADOCmd.Execute(,,adExecuteStream) strXML = strmXMLOut.ReadText strXML = "<XML>" + strXML + "</XML>" STRTOFILE(strXML, "XMLOutStream.txt") && Helpful to see what SQL Server returned *-- Create cursor and set buffering so that an updategram can be created XMLTOCURSOR(strXML,"csrTemp") CURSORSETPROP("Buffering",5,"csrTemp") *-- Set KeyFields -- mucho importante! CURSORSETPROP("KeyFieldList","employeeid","csrTemp") BROWSE && Edit the Notes field for employeeID=1 *-- Create an XML Update file and string strXML = XMLUPDATEGRAM("csrTemp",0+8+32) strXML = STRTRAN(strXML,"csrtemp","employees") STRTOFILE(strXML,"XMLUpdate.xml") *-- Update SQL Server strmXMLIn.Open strmXMLIn.Charset = "UTF-8" strmXMLIn.WriteText = strXML strmXMLIn.Position = 0 oADOCmd.CommandStream = strmXMLIn *-- If the notes field was one of the modified fields * this will give the error: * "...The text, ntext, and image data types cannot be compared * or sorted, except when using IS NULL or LIKE operator..." oADOCmd.Execute(,,adExecuteStream) SUSPEND CLOSE TABLES ALL