VB Code:
  1. <%@ Page Language="C#" Debug="true"%>
  2. <%@ Import Namespace="System.Data"%>
  3. <%@ Import Namespace="System.Data.OleDb"%>
  4.  
  5.  
  6. <SCRIPT LANGUAGE="C#" Runat="server">
  7.     OleDbCommand cmd;
  8.     static String pathinfo="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:/InetPub/wwwroot/database/buyerStats.mdb";
  9.     OleDbConnection conn = new OleDbConnection(pathinfo);
  10.     int dr;
  11.     void Page_Load(object sender, System.EventArgs e)
  12.     {
  13.     double amount = 0.0;
  14.     string cmdText = "select sum ( poamount ) as amount from [stats] where buyer = 'Brad' group by poamount";
  15.     using (cmd = new OleDbCommand(cmdText, conn))
  16.     {
  17.         try
  18.         {
  19.             cmd.Connection.Open();
  20.             object result = cmd.ExecuteScalar();
  21.             if (result != null)
  22.             {
  23.                 amount = System.Convert.ToDouble(result);
  24.             }
  25.         }
  26.         finally
  27.         {
  28.             if (cmd != null && cmd.Connection != null)
  29.             {
  30.                 cmd.Connection.Close();
  31.             }
  32.         }
  33.     }
  34.     conn.Close();
  35.     }
  36. </SCRIPT>
  37. <html>
  38. <body>
  39. <form runat="server">
  40.     Number of Pos:<asp:Literal id="amount" runat="server" />
  41. </form>
  42. </body>
  43. </html>