运行我的代码后,它会显示以下消息:
此子查询最多可以返回一条记录。
那么,我怎样才能得到所有的鱼尾?
这是我的代码:
connection.Open();
OleDbCommand command1 = new OleDbCommand();
command1.Connection = connection;
string cq = "Select Email From student where S_ID=(select S_ID FROM studentbook where DateDiff('d',[Issue_Date], NOW())=31) ";
command1.CommandText = cq;
OleDbDataAdapter da1 = new OleDbDataAdapter(command1);
DataTable dt1 = new DataTable();
da1.Fill(dt1);
foreach (DataRow row in dt1.Rows)
{
string email = row["Email"].ToString();
MessageBox.Show("Trying to send email ");
using (MailMessage mm = new MailMessage("sujitcsecuet@gmail.com", email))
{
mm.Subject = "Attention please,renew your book";
mm.Body = string.Format("1 month over,you should renew or return the book");
mm.IsBodyHtml = true;
SmtpClient smtp = new SmtpClient();
smtp.Host = "smtp.gmail.com";
smtp.EnableSsl = true;
System.Net.NetworkCredential credentials = new System.Net.NetworkCredential();
credentials.UserName = "abc@gmail.com";
credentials.Password = "password";
smtp.UseDefaultCredentials = true;
smtp.Credentials = credentials;
smtp.Port = 587;
smtp.Send(mm);
MessageBox.Show("Email sent successfully");
}
}