Modifying Large Text and Binary Fields
You can use a Stream object to retrieve data from columns that hold large amounts of data, such as XML and varbinary columns. Now let’s take a look at a couple examples that demonstrate how to insert data into those columns. For these examples, I used the SQL statement in Callout C of Listing 1 to add XML and varbinary columns to the Production.Inventory table.
The code in Listing 7 uses a Stream object to insert data into the Model column, which is defined with an XML data type. The source data is the Road250Model.xml file, which I generated by extracting data from the Instructions column of the Production.ProductModel table. If you run this script, be sure to change the path and file name to the correct XML file. For this script, I first define the connection string and then the command text. Next, I create a Recordset object, set the cursor location, and use the object’s Open method to populate the recordset. When I call the method, I specify the same options that I used in Listing 6, except that I reference the connection string, rather than a connection object. . . .