i have database of transaction
and table name is LOg_header
and it have columns one is Resp_code
and 2nd is Date
my job is to select failure transaction 3 in a row. like '01'
and alert email
to email address that 3 transaction is failed in a row.
and if there is no failure transaction all are successfull like '00'
email alert too that all things going fine.
through C# console applicaiton
.
here is my code i m stuck what to do kindly help.
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();
}
}
}