저는 C# 프로젝트에서 작업 중이며 현재 MySQL 데이터 판독기에 문제가 있습니다. 이하 더 많은 행이있을 때 MySQLDataReader가 한 번만 반복됩니다.
제가try
{
using (ConnectMySQLDB db = new ConnectMySQLDB(Configuration.databaseSettings))
{
string query = "SELECT COUNT(*) AS `TotalRows`, reports.id AS `BugID`, DateReported, Software, Platform, Version, FirstName, "
+ "LastName, Email, Summary, BugDescription, PinCode, SendUpdates, Priority, Summary "
+ "FirstName, LastName, Email, Summary, "
+ "bug_updates.id AS `UpdateID`, UpdateMessage FROM reports, software, platforms, versions, bug_updates "
+ "WHERE reports.SoftwareID = software.id AND reports.PlatformID = platforms.id "
+ "AND reports.VersionID = versions.id AND reports.id = 1 AND reports.id = bug_updates.BugID AND SendUpdates=1 "
+ "AND BugUpdateNotificationSent='0'";
using (MySqlCommand cmd = new MySqlCommand(query, db.conn))
{
using (MySqlDataReader reader = cmd.ExecuteReader())
{
while (reader.Read())
{
totalEmails = reader.GetInt32("TotalRows");
library.logging(methodInfo, string.Format("Found {0} bugs requiring update notification", totalEmails));
if (totalEmails > 0)
{
currentEmailCount++;
EmailNotifications emailNotifications = new EmailNotifications(reader);
emailNotifications.sendBugReportUpdateEmailNotification(currentEmailCount, totalEmails);
}
else
{
library.logging(methodInfo, "No emails requiring to be sent for update notification");
}
}
}
}
}
}
catch (MySqlException ex)
{
string error = string.Format("Failed to check if updates need to be sent. MySQL Error: {0}", ex.Message);
library.logging(methodInfo, error);
library.setAlarm(error, CommonTasks.AlarmStatus.Medium, methodInfo);
}
catch (Exception ex)
{
string error = string.Format("Failed to check if updates need to be sent. General Error: {0}", ex.Message);
library.logging(methodInfo, error);
library.setAlarm(error, CommonTasks.AlarmStatus.Medium, methodInfo);
}
I 코드를 단계별 때 문제가
사용시, 그것은 데이터 판독기의 판독을 수행하는 루프 enetrs 코드이며, 전체 행은 13로 설정 얻을 따라서 데이터 리더에는 13 개의 행이 있습니다. 루프 내에서 모든 것을 성공적으로 완료했지만 어떤 이유로 루프에서 빠져 나와 나머지 행은 통과하지 않습니다.
도움을 주셔서 감사합니다.
선택 개수 (*)는 한 행만 반환하며 어떻게 실행되는지는 잘 모르겠습니다. 선택 목록에서 집계 함수를 사용할 때 Group By 절이 필요하지 않습니까? MySQL은 이것을 요구하지 않습니까? –
'AND reports.id = 1'이 (가) 13 개의 레코드가 있습니까? – Steve
약간의 조사가 끝나면 MySql에서 Group By 절없이 선택 목록에 추가 열을 포함 할 수 있습니다. –