Default.aspx.cs
上传用户:woolgirl
上传日期:2020-04-18
资源大小:243k
文件大小:4k
源码类别:

SCSI/ASPI

开发平台:

Others

  1. using System;
  2. using System.Data;
  3. using System.Data.OleDb;//ACCESS
  4. using System.Configuration;
  5. using System.Collections;
  6. using System.Web;
  7. using System.Web.Security;
  8. using System.Web.UI;
  9. using System.Web.UI.WebControls;
  10. using System.Web.UI.WebControls.WebParts;
  11. using System.Web.UI.HtmlControls;
  12. public partial class _Default : System.Web.UI.Page
  13. {
  14.     public void page_Load(Object sender, EventArgs e)
  15.     {
  16.         //OleDbConnection conn = new OleDbConnection("Provider=Microsoft.JET.OLEDB.4.0;Data Source=" + System.Web.HttpContext.Current.Server.MapPath("liuyin_data/data.mdb") + ";"); 
  17.         OleDbConnection conn = liuyinconn.connstr();
  18.         try
  19.         {
  20.             conn.Open();//打开数据库链接 ;
  21.             //Response.Write("链接成功!");
  22.             conn.Close();//关闭数据库链接;
  23.         }
  24.         catch
  25.         {
  26.            // Response.Write("参数错误!");
  27.         }
  28.     }
  29.     public string msg_top()
  30.     //留言列表
  31.     {
  32.         string msg_top = "";
  33.         try
  34.         {
  35.             OleDbConnection conn = liuyinconn.connstr();
  36.             string TableName = "yl_message";
  37.             string sql = "Select TOP 10 * FROM [" + TableName + "]  WHERE yl_sh=0 ORDER BY yl_adddate DESC";
  38.             conn.Open();//打开数据库链接 ;
  39.             OleDbCommand cmd = new OleDbCommand(sql, conn);
  40.             OleDbDataReader rs = cmd.ExecuteReader();
  41.             if (rs.HasRows)
  42.             {
  43.                
  44.                 while (rs.Read())
  45.                 {
  46.                     Response.Write("<div class='ct'>");
  47.                     Response.Write("<div class='cta'>");
  48.                     Response.Write("<strong>&nbsp;标题:" + rs["yl_title"].ToString() + "</strong>");
  49.                     Response.Write("</div>");
  50.                     Response.Write("<div class='ctb'>");
  51.                     Response.Write("操作");//文字广告
  52.                     Response.Write("</div>");
  53.                     Response.Write("</div>");
  54.                     Response.Write("<div class='cl'>");
  55.                     Response.Write("<div class='clc'>");
  56.                     Response.Write("" + rs["yl_body"].ToString() + "");
  57.                   //  Response.Write("<br><br>");
  58.                   //  if (rs["yl_uid"].ToString() != "0")
  59.                   //  {
  60.                   //      Response.Write("<div class=review>");
  61.                   //      Response.Write("" + rs["yl_uidHF"].ToString() + "");
  62.                   //      Response.Write("</div>");
  63.                   //  }
  64.                     
  65.                     Response.Write("</div>");
  66.                     Response.Write("<div class='clinfo'>");
  67.                     
  68.                     Response.Write("</div>");
  69.                     Response.Write("<div class='clin'>");
  70.                     Response.Write("<div class='lefts'>");
  71.                     Response.Write("<strong>&nbsp;</strong>");//文字广告
  72.                     Response.Write("</div>");
  73.                     Response.Write("<div class='rights'>");
  74.                     Response.Write("<strong>&nbsp;发表:</strong>" + rs["yl_name"].ToString() + "");
  75.                     Response.Write("<strong>&nbsp;时间:</strong>" + rs["yl_adddate"].ToString() + "");
  76.                     Response.Write("</div></div>");
  77.                     Response.Write("</div>");
  78.                     //Response.Write("<IMG src=skins/1/FACE/" + rs["yl_face"].ToString() + " border=0>");
  79.                 }
  80.             }
  81.             rs.Close();
  82.             conn.Close();
  83.         }
  84.         catch
  85.         {
  86.             Response.Write("参数错误!");
  87.         }
  88.         return msg_top;
  89.     }
  90. }