I am doing a college attendance project (Winforms, Mysql, C#)
I want to update 0 to P, 1 to Ab and 2 to OD in all period columns. For that I write a for loop and three update query.
Is it any possible idea for do this in one single query?
Please help me…
for (int i = 1; i <= 8; i++)
{
string period = "Period" + i;
string t1p = period1;
command.CommandText = "update attendance_daily_rpt set " + t1p + " = 'P' where " + t1p + " = 0";
connection.Open();
command.ExecuteNonQuery();
connection.Close();
command.CommandText = "update attendance_daily_rpt set " + t1p + " = 'Ab' where " + t1p + " = 1";
connection.Open();
command.ExecuteNonQuery();
connection.Close();
command.CommandText = "update attendance_daily_rpt set " + t1p + " = 'OD' where " + t1p + " = 2";
connection.Open();
command.ExecuteNonQuery();
connection.Close();
}
Thanks in advance…
SQL:
Make C# string yourself 😉