我在Windows服务的项目里用到了一个Timer控件,发现在Windows服务(我这是VS2005)里,Timer控件的Tick事件没有作用。服务已经启动了但实际并未对数据库产生操作。请问这是为什么?Timer的Enalbed我已经设成了True. Interval我设成了1000。Timer中取自组件栏里的。代码是这样的:
 protected override void OnStart(string[] args)
        {
            // TODO: 在此处添加代码以启动服务。
            this.timer1.Enabled = true;
          
        }        protected override void OnStop()
        {
            // TODO: 在此处添加代码以执行停止服务所需的关闭操作。
            this.timer1.Enabled = false;
                  }  private void timer1_Tick(object sender, EventArgs e)
{
           
 SqlConnection conn = new SqlConnection("server=(local);database=sxl;uid=sa;pwd=;");
 SqlCommand comm = new SqlCommand("insert into sxlxxy(WEIJIBIANMA,NASHUIRENJC) values('111','111')", conn);
 conn.Open();
comm.ExecuteNonQuery();
conn.Close(); 
}