home *** CD-ROM | disk | FTP | other *** search
/ ftp.tcs3.com / ftp.tcs3.com.tar / ftp.tcs3.com / DRIVERS / Audio / Office2010 / InfoPath.en-us / InfLR.cab / FL_CreateParameterizedSelectCommand_snippe_142629_ENU____.3643236F_FC70_11D3_A536_0090278A1BB8 < prev    next >
Extensible Markup Language  |  2008-09-17  |  3KB  |  75 lines

  1. <?xml version="1.0"?>
  2. <CodeSnippets xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
  3.   <CodeSnippet Format="1.0.0">
  4.     <Header>
  5.       <Title>Create a Parameterized SELECT Command</Title>
  6.       <Author>Microsoft Corporation</Author>
  7.       <Description>Calls the ExecuteReader method of a data command to execute a Select statement.</Description>
  8.       <Shortcut>adoSelectwParams</Shortcut>
  9.     </Header>
  10.     <Snippet>
  11.       <References>
  12.         <Reference>
  13.           <Assembly>System.Data.dll</Assembly>
  14.         </Reference>
  15.         <Reference>
  16.           <Assembly>System.Xml.dll</Assembly>
  17.         </Reference>
  18.       </References>
  19.       <Imports>
  20.         <Import>
  21.           <Namespace>System.Data.SqlClient</Namespace>
  22.         </Import>
  23.         <Import>
  24.           <Namespace>System.Data</Namespace>
  25.         </Import>
  26.       </Imports>
  27.       <Declarations>
  28.         <Literal>
  29.           <ID>SQL</ID>
  30.           <Type>String</Type>
  31.           <ToolTip>Replace with a SQL statement.</ToolTip>
  32.           <Default>SELECT CustomerID, CompanyName FROM Customers WHERE CompanyName LIKE @companyName</Default>
  33.         </Literal>
  34.         <Object>
  35.           <ID>parameter1</ID>
  36.           <Type>SqlParameter</Type>
  37.           <ToolTip>Replace with the name of the parameter referenced in code.</ToolTip>
  38.           <Default>companyNameParam</Default>
  39.         </Object>
  40.         <Literal>
  41.           <ID>sqlParameterName</ID>
  42.           <Type>String</Type>
  43.           <ToolTip>Replace with the SQL Parameter in your query.</ToolTip>
  44.           <Default>@companyName</Default>
  45.         </Literal>
  46.         <Literal>
  47.           <ID>parameterValue</ID>
  48.           <Type>String</Type>
  49.           <ToolTip>Replace with the value for the parameter.</ToolTip>
  50.           <Default>"a%"</Default>
  51.         </Literal>
  52.         <Object>
  53.           <ID>conn</ID>
  54.           <Type>SqlConnection</Type>
  55.           <ToolTip>Replace with a connection object.</ToolTip>
  56.           <Default>conn</Default>
  57.         </Object>
  58.         <Object>
  59.           <ID>cmd</ID>
  60.           <Type>SqlCommand</Type>
  61.           <ToolTip>Replace with the object name for your SqlCommand.</ToolTip>
  62.           <Default>cmd</Default>
  63.         </Object>
  64.       </Declarations>
  65.       <Code Language="VB" Kind="method body"><![CDATA[Dim $cmd$ As New SqlCommand
  66. $cmd$.CommandType = CommandType.Text
  67. $cmd$.CommandText = "$SQL$"
  68. $cmd$.Connection = $conn$
  69. ' Create a SqlParameter for each parameter in the stored procedure.
  70. Dim $parameter1$ As New SqlParameter("$sqlParameterName$", $parameterValue$)
  71. $cmd$.Parameters.Add($parameter1$)
  72. ]]></Code>
  73.     </Snippet>
  74.   </CodeSnippet>
  75. </CodeSnippets>