The NGWS frameworks and runtime has a DataGrid class that makes the display of large databases an easier task. This section describes how to access a SQL database and bind that data to a DataGrid object. It uses a "select *" SQL query to get all rows and columns of data from the database. Sections that follow this one will then show how to manage that data.
To access a SQL database
<%@ Import Namespace="System.Data" %> <%@ Import Namespace="System.Data.SQL" %>
<script language="C#" runat="server"> public DataView Source; protected void Page_Load(Object Src, EventArgs E ) {
SQLConnection myConnection = new SQLConnection("server=localhost;uid=sa;pwd=;database=pubs");
SQLDataSetCommand myCommand = new SQLDataSetCommand("select * from Authors", myConnection);
DataSet ds = new DataSet(); myCommand.FillDataSet(ds, "Authors");
Source = new DataView(ds.Tables[0]); MyDataGrid.DataSource=Source ; MyDataGrid.DataBind(); } </script>
<body>
<h3><font face="Verdana">Simple Select to a DataGrid Control</font></h3>
<ASP:DataGrid id="MyDataGrid" runat="server" Width="700" BackColor="#ccccff" BorderColor="black" ShowFooter="false" CellPadding=3 CellSpacing="0" Font-Name="Verdana" Font-Size="8pt" HeaderStyle-BackColor="#aaaadd" MaintainState="false" /> </body>
To see this example run, go to the ASP+ Quick Start and run sample DataGrid1.aspx.