SEARCH
0-9 A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
Prev | Current Page 79 | Next

Joydip Kanjilal

"ASP.NET Data Presentation Controls Essentials"

The code for this method is as follows:
public ArrayList GetSortedEmployees(string sortColumn)
{
SqlConnection conn = null;
ArrayList employeeList = null;
try
{
conn = new SqlConnection(connectionString);
conn.Open();
string sql = "select EmpCode, EmpName, Basic,
JoiningDate, DeptCode from employee e, Department d
where e.DeptID = d.DeptID" + " Order By "+sortColumn;
SqlCommand cmd = new SqlCommand(sql, conn);
SqlDataReader dr = cmd.ExecuteReader();
employeeList = new ArrayList();
while (dr.Read())
{
Employee emp = new Employee();
if (dr["EmpCode"] != DBNull.Value)
emp.EmpCode = dr["EmpCode"].ToString();
if (dr["EmpName"] != DBNull.Value)
emp.EmpName = dr["EmpName"].ToString();
if (dr["Basic"] != DBNull.Value)
emp.Basic = Convert.ToDouble(dr["Basic"].ToString());
if (dr["JoiningDate"] != DBNull.Value)
emp.JoiningDate =
Convert.ToDateTime(dr["JoiningDate"].ToString());
if (dr["DeptCode"] != DBNull.Value)
emp.DeptCode = dr["DeptCode"].ToString();
employeeList.Add(emp);
emp = null;
}
}
Working with the Repeater Control
[ 80 ]
catch
{
throw;
}
finally
{
Dr.Close(); conn.Close();
}
return employeeList;
}
Once you are done with the DataReader, you must always close it
, by calling the Close() method on the DataReader instance. Unless
you close a DataReader, you cannot execute any commands using the
, Connection instance on which the DataReader has been used.


Pages:
67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91
hotel jelenia góra Russian bride Free English grammar and study guid powiekszenia wielkoformatowe counter strike 1.6