--- title: "Using an Updategram in a Sample ASP Application (SQLXML 4.0) | Microsoft Docs" ms.custom: "" ms.date: "03/06/2017" ms.prod: "sql-server-2014" ms.reviewer: "" ms.technology: xml ms.topic: "reference" helpviewer_keywords: - "ASP applications [SQLXML]" - "Active Server Pages" - "updategrams [SQLXML], ASP applications" ms.assetid: 10eff799-4c39-4b52-8b38-7ea6f68454a8 author: MightyPen ms.author: genemi manager: craigg --- # Using an Updategram in a Sample ASP Application (SQLXML 4.0) This Active Server Pages (ASP) application allows you to update customer information in the Person.Contact table in the AdventureWorks sample database in Microsoft [!INCLUDE[ssNoVersion](../../../includes/ssnoversion-md.md)]. The application does the following: - Asks the user to enter a contact ID. - Uses this customer ID value to execute a template to retrieve contact information from the Person.Contact table. - Displays this information by using an HTML form. The user can then update contact information but not the contact ID (because the ContactID is the primary key). After the user submits the information, an updategram is executed and all the form parameters are passed to the updategram. The following template is the first template (GetContact.xml). Save this template in the directory that is associated with the virtual name of `template` type. ``` SELECT * FROM Person.Contact WHERE ContactID=@cid FOR XML AUTO ``` The following template is the second template (UpdateContact.xml). Save this template in the directory that is associated with the virtual name of `template` type. ``` ``` The following code is the ASP application (SampleASP.asp). Save it in the directory that is associated with a virtual root that you create by using the Internet Services Manager utility. (This virtual root is not created by using the IIS Virtual Directory Management for [!INCLUDE[ssNoVersion](../../../includes/ssnoversion-md.md)] utility because IIS Virtual Directory Management for [!INCLUDE[ssNoVersion](../../../includes/ssnoversion-md.md)] cannot access or identify ASP applications.). > [!NOTE] > In the code, you must replace "ServerName" with the name of the server running Microsoft Internet Information Services (IIS). ``` <% LANGUAGE=VBSCRIPT %> <% Dim ContactID ContactID=Request.Form("cid") %> <% 'If a ContactID value is not yet provided, display this form. if ContactID="" then %>

Enter ContactID:


<-- Otherwise, if a ContactID is entered, display the second part of the form where the user can change customer information. --> <% else %> You may update customer information below.


<% ' Load the document in the parser and extract the values to populate the form. Set objXML=Server.CreateObject("MSXML2.DomDocument") ObjXML.setProperty "ServerHTTPRequest", TRUE objXML.async=False objXML.Load("http://localhost/AdventureWorks/Template/GetContact.xml?cid=" & ContactID) set objCustomer=objXML.documentElement.childNodes.Item(0) ' In retrieving data from the database, if a value in the column is NULL there ' is no attribute for the corresponding element. In this case, ' skip the error generation and go to the next attribute. On Error Resume Next Response.Write "Contact ID:

" Response.Write "Title:

" Response.Write "First Name:
" Response.Write "Last Name:

" Response.Write "Email Address:

" Response.Write "Phone:

" set objCustomer=Nothing Set objXML=Nothing %>



<% end if %>
``` ## See Also [Updategram Security Considerations (SQLXML 4.0)](../security/updategram-security-considerations-sqlxml-4-0.md)