I ran into another issue again. I was trying to get data from the database using DataReader but I got the error when i was testing my code. Can anyone help me out? The error occurred at this line:
chkAssess = readAssess[columnName].ToString();
Below is the code snippet:
public string CheckAssess(string emailAddress, string columnName)
{
    string chkAssess = "";
    SqlDataReader readAssess;
    //readAssess = new SqlDataReader();
    string MgrAssessQry = "SELECT '"+columnName+"' FROM tblAllUsers";
    //MgrAssessQry += " WHERE email ='" + emailAddress + "'";
    SqlCommand cmdReadAssess = new SqlCommand(MgrAssessQry, cn);
    cn.Open();
    readAssess = cmdReadAssess.ExecuteReader();
    while(readAssess.Read())
    {
        // Add the rows
        chkAssess = readAssess[columnName].ToString();         
    }
    return chkAssess;
}
 
     
     
     
     
    