13.07.2015 Views

Applied XML Programming for Microsoft .NET.pdf - Csbdu.in

Applied XML Programming for Microsoft .NET.pdf - Csbdu.in

Applied XML Programming for Microsoft .NET.pdf - Csbdu.in

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

that throughout the Updategram. The nullvalue attribute <strong>in</strong>dicatesthe alternative text, as shown here:...Submitt<strong>in</strong>g Commands Through UpdategramsUpdategrams can be executed <strong>in</strong> various ways. You can send the Updategram text toSQL Server over HTTP. Alternatively, you can write the <strong>XML</strong> contents out to a file andthen po<strong>in</strong>t the browser (or any other HTTP-enabled software) to that URL so that thecontents are executed. Or you can use an Updategram with ADO.The follow<strong>in</strong>g Visual Basic 6.0 code shows how to proceed. Notice that you must copythe Updategram to a stream and receive the response over another stream object.Dim cmd As New ADODB.CommandDim conn As New ADODB.ConnectionDim strIn As New ADODB.StreamDim strOut As New ADODB.Streamconn.Provider = "SQLOLEDB"conn.Open "SERVER=localhost;DATABASE=northw<strong>in</strong>d;UID=sa;"conn.Properties("SQL<strong>XML</strong> Version") = "SQL<strong>XML</strong>.3.0"Set cmd.ActiveConnection = conncmd.Dialect = "{5d531cb2-e6ed-11d2-b252-00c04f681b71}"strIn.OpenstrIn.WriteText SQLxmlstrIn.Position = 0Set cmd.CommandStream = strInstrOut.Opencmd.Properties("Output Stream").Value = strOutcmd.Properties("Output Encod<strong>in</strong>g").Value = "UTF-8"cmd.Execute , , adExecuteStreamNotice also that you need to set the command dialect to a particular globally uniqueidentifier (GUID)—DBGUID_MSSQL<strong>XML</strong>—and set a few properties on the commandand the connection objects.Concurrency IssuesUpdategrams are batches that work by loop<strong>in</strong>g on source data and execut<strong>in</strong>g asequence of commands. What happens if, due to the system concurrency, rows thatyou are go<strong>in</strong>g to modify have been changed s<strong>in</strong>ce the time you last read them?312

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!