home *** CD-ROM | disk | FTP | other *** search
/ PC World 2003 September / PCWorld_2003-09_cd.bin / Software / Vyzkuste / webmatrix / WebMatrix.msi / Data1.cab / _650D674792D442BEA082E2A7368130B4 < prev    next >
Encoding:
ASP.NET Web Form  |  2003-04-28  |  1.4 KB  |  38 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 and CommandText values for your application
  10.         string ConnectionString = "server=(local);database=pubs;trusted_connection=true";
  11.         string CommandText = "select au_lname as [Last Name], au_fname as [First Name], Address, City, State from Authors";
  12.         
  13.         SqlConnection myConnection = new SqlConnection(ConnectionString);
  14.         SqlCommand myCommand = new SqlCommand(CommandText, myConnection);
  15.  
  16.         myConnection.Open();
  17.  
  18.         DataGrid1.DataSource = myCommand.ExecuteReader(CommandBehavior.CloseConnection);
  19.         DataGrid1.DataBind();   
  20.     }
  21.     
  22. </script>
  23.     
  24. <html>
  25.     <body style="font-family:arial">
  26.         <h2>
  27.             Simple Data Report
  28.         </h2>
  29.         <hr size="1">
  30.         <form runat="server">
  31.             <asp:datagrid id="DataGrid1" EnableViewState="False" runat="server" ForeColor="Black" BackColor="White" CellPadding="3" GridLines="None" CellSpacing="1">
  32.                 <HeaderStyle Font-Bold="True" ForeColor="white" BackColor="#4A3C8C"></HeaderStyle>
  33.                 <ItemStyle BackColor="#DEDFDE"></ItemStyle>
  34.             </asp:datagrid>
  35.         </form>
  36.     </body>
  37. </html>
  38.