home *** CD-ROM | disk | FTP | other *** search
/ PC World 2003 September / PCWorld_2003-09_cd.bin / Software / Vyzkuste / webmatrix / WebMatrix.msi / Data1.cab / _2C45ED7E451645D2B76A26DFFCDC971E < prev    next >
Encoding:
ASP.NET Web Form  |  2003-04-28  |  1.6 KB  |  48 lines

  1. <%@ Page language="C#"%%ClassName, ClassName="{0}"%% %>
  2. <%@ Import Namespace="System.Data" %>
  3. <%@ Import Namespace="System.Data.SqlClient" %>
  4.  
  5. <script runat="server">
  6.  
  7.     void Page_Load(object sender, EventArgs e) {
  8.  
  9.         // TODO: Update the ConnectionString for your application
  10.         string ConnectionString = "server=(local);database=Northwind;trusted_connection=true";
  11.  
  12.         // TODO: Updatd the name of the Stored Procedure for your application
  13.         string CommandText = "CustOrdersDetail";
  14.         
  15.         SqlConnection myConnection = new SqlConnection(ConnectionString);
  16.         SqlCommand myCommand = new SqlCommand(CommandText, myConnection);
  17.         SqlParameter workParam;
  18.  
  19.         myCommand.CommandType = CommandType.StoredProcedure;
  20.  
  21.         // TODO: Set the input parameter, if necessary, for your application
  22.         myCommand.Parameters.Add("@OrderId", SqlDbType.Int).Value = 11077;
  23.  
  24.  
  25.  
  26.         myConnection.Open();
  27.  
  28.         DataGrid1.DataSource = myCommand.ExecuteReader(CommandBehavior.CloseConnection);
  29.         DataGrid1.DataBind();   
  30.     }
  31.     
  32. </script>
  33.     
  34. <html>
  35.     <body style="font-family:arial">
  36.         <h2>
  37.             Simple Stored Procedure
  38.         </h2>
  39.         <hr size="1">
  40.         <form runat="server">
  41.             <asp:datagrid id="DataGrid1" EnableViewState="False" runat="server" ForeColor="Black" BackColor="White" CellPadding="3" GridLines="None" CellSpacing="1">
  42.                 <HeaderStyle Font-Bold="True" ForeColor="white" BackColor="#4A3C8C"></HeaderStyle>
  43.                 <ItemStyle BackColor="#DEDFDE"></ItemStyle>
  44.             </asp:datagrid>
  45.         </form>
  46.     </body>
  47. </html>
  48.