我有交易数据库,table 名称是 LOg_header,它的第一列是 Resp_code,第二列是日期

i have database of transaction and table name is LOg_header and it have columns one is Resp_code and 2nd is Date

我有 database of transaction 和 table 名字是 LOg_header 它有第一列是 Resp_code 第二列是 Date

我的工作是 select 连续 3 笔交易失败。喜欢 '01'alert email 到连续 3 笔交易失败的电子邮件地址。 如果没有失败交易,则所有交易都成功,如“00” 电子邮件提醒一切顺利。

C# console applicaiton

这是我的代码,我不知道该怎么办,请帮忙。

namespace Email
{
    class Program
    {
        public static void email_send()
        {    
            MailMessage mail = new MailMessage();
            SmtpClient SmtpServer = new SmtpClient("smtp.gmail.com");
            mail.From = new MailAddress("hh@hotmail.com");
            mail.To.Add("ushhh@hotmail.com");
            mail.Subject = "Test Mail - 1";
            mail.Body = "mail with attachment";

            System.Net.Mail.Attachment attachment;
            attachment = new System.Net.Mail.Attachment(@"C:/ProductId.txt");
            mail.Attachments.Add(attachment);

            SmtpServer.Port = 587;
            SmtpServer.Credentials = new System.Net.NetworkCredential("usm@.com", "*******");
            SmtpServer.EnableSsl = true;

            SmtpServer.Send(mail);

        }
        static void Main(string[] args)
        {
            string connectionString = ConfigurationManager.ConnectionStrings["MySwipe"].ConnectionString;
            using (SqlConnection connection = new SqlConnection(connectionString))
            {
                connection.Open();
                using (SqlCommand command = new SqlCommand("select  TOP 3 [Resp_Code],JV_Date from dbo.log_jv_header order by JV_Date desc", connection))
                {
                    using (SqlDataReader dataReader = command.ExecuteReader())
                    {
                        if (!dataReader.HasRows)
                        {
                          //NO idea what to do..
                        }
                    }
                }
            }

            email_send();
            Console.WriteLine("Email Send to Operations Department.");
            Console.ReadLine();
        }
    }
}
 static bool HasFaildSessions()
    {
        int counter = 0;
        bool result = false;
        string connectionString = ConfigurationManager.ConnectionStrings["MySwipe"].ConnectionString;
        using (SqlConnection connection = new SqlConnection(connectionString))
        {
            connection.Open();
            using (SqlCommand command = new SqlCommand("select  TOP 3 [Resp_Code],JV_Date from dbo.log_jv_header order by JV_Date desc", connection))
            {
                using (SqlDataReader dataReader = command.ExecuteReader())
                {


                    while (dataReader.Read())
                    {
                        if (string.Equals(dataReader.GetString(0), "01"))
                            counter++;
                    }
                }
            }
        }

        if (counter == 3)
            result = true;

        return result;
    }

    static void Main(string[] args)
    {
        While(true) //infinite loop
        {
        if (HasFaildSessions())
        {
            email_send();

            Console.WriteLine("Email Send to Operations Department.");
            Console.ReadLine();
        }
        Thread.Sleep(300000);
        }
    }