如果数据库里的某个表在一个小时里没有数据资料转入(有一个专门的程序转数据资料到这个表里),那么自动发送EMAIL给某个人,EMIAL的内容是告诉某个人让他重新启动转数据资料的程序.因为表里长时间没有数据资料转入往往是因为转数据资料的程序需要重新启动,所以需要EMAIL告诉某个人让他重新启动转数据资料的程序...请问这样的功能怎么实现?

解决方案 »

  1.   

    可以判断,在.net2.0的新功能介绍里面就有讲到,
    1.对于SQL2000及以前的版本,轮询.
    2.对于SQL2005,数据表改变之后可以自动发送一个事件.
      

  2.   

    写一个服务定时检索表中最后一次置入记录的时间.如果超时则发送EMAIL
      

  3.   

    每一小时检测表的变化,无变化就发Email
      

  4.   

    判断一小时后数据库是否为空,如是就发送Email
      

  5.   

    可以用Windows服务每隔一小时读取表的记录数,存放于另一表中,如果记录无变化,则通过Email服务器发送一封Mail,发Mail见
    http://dev.csdn.net/develop/article/82/82119.shtm
      

  6.   

    using System; 
    using System.Data; 
    using System.Data.OleDb; 
    using System.Web.UI; 
    using System.Web.UI.WebControls; 
    using System.Web.UI.HtmlControls; 
    using System.Web.Mail;
    using System.Data.SqlClient;
    using System.Configuration;
    using System.Text;namespace www
    {
    public class MyCodeBehind : Page 

    public DataGrid     MyList; 
            public TextBox   TextBox1,TextBox2,TextBox3,TextBox4,txtIndex;
    public LinkButton   btnFirst,btnPrev,btnNext,btnLast; 
    public Label     lblCurrentPage,lblPageCount,lblRecordCount,Lbl_note,label1,label2; 
    public DataRow dr,dr0,dr1;
    public int PageCount,RecordCount,sum1=0,sum11=0; 
    public string status,subject1,body1="",body2="";
     
    private void Page_Load(Object sender, EventArgs e)    
    {     
    string nowDSN=ConfigurationSettings.AppSettings["data"];
        SqlConnection myConnection=new SqlConnection(nowDSN);
        SqlDataAdapter myCommand=new SqlDataAdapter("select * from pur",myConnection);
        DataSet ds=new DataSet();    
    myCommand.Fill(ds, "pur");  
    dr = ds.Tables["pur"].Rows[0];
        int pur_count=ds.Tables["pur"].Rows.Count;                string CommandText; 
                    SqlCommand myCommand0 = new SqlCommand();
                    myCommand0.Connection=myConnection;
    myCommand0.Connection.Open();
    myCommand0.CommandText = "select pur_count from pur_count where id='1'";
    int pur_count0=(int)myCommand0.ExecuteScalar();  if(pur_count > pur_count0)     
        {
    myCommand0.CommandText = "update pur_count set pur_count='"+pur_count+"' where id='1'";
    myCommand0.ExecuteNonQuery();
    myCommand0.Connection.Close();
    Response.Write("正在转WEB资料程序!");
    }
    else
        {
        SmtpMail.SmtpServer="mail.lw-org.com";
    MailMessage oMessage = new MailMessage();
    oMessage.BodyFormat = MailFormat.Html;
    oMessage.Priority = MailPriority.High;
    oMessage.From = "[email protected]";
    oMessage.To = "[email protected]"; 
    oMessage.Bcc = "[email protected]";
    oMessage.BodyEncoding = Encoding.UTF8;
    oMessage.Subject = "?";
    oMessage.Body = "烦重启转WEB资料程序";
    SmtpMail.Send(oMessage); 
    Response.Write("烦重启转WEB资料程序!");
    }
    }
    }
    }