I have a problem. I have a table named "RollNoSlip" which has a column named "AttendanceStatus". I have list variable named "getAttendance" of type "List<string>". I want to assign each values to each record of "RollNoSLip". Attendance column can contain "P" or "A". Problem is its showing only P in all records. Why?
var getAttendance = (from r in db.RollNoSlips
from a in db.Attendances
where r.RollNo == a.RollNo
select a.AttendanceStatus).ToList();
using (var con = new SqlConnection(ConfigurationManager.ConnectionStrings["IQTSConnectionString"].ConnectionString))
{
con.Open();
using (var cmd = new SqlCommand("update RollNoSlip set AttendanceStatus=@Attendance where RollNo between 10001 and 10045", con))
{
cmd.Parameters.Add("@Attendance", SqlDbType.VarChar);
for (int i = 0; i < getAttendance.Count; i++)
{
cmd.Parameters["@Attendance"].Value = getAttendance[i];
cmd.ExecuteNonQuery();
}
}
}