Calendar引发的"惨案",菜鸟求助"超时时间已到,但是尚未从池中获取连接"
新做了一个工作行程安排,用到了calendar,当时有一个小小想法,想在calendar的每一天上显示当天行程安排的记录总数,
所以在DayRender添加了以下代码:
protected void Calendar1_DayRender(object sender, DayRenderEventArgs e)
{
string day = e.Day.Date.ToString( "yyyy-MM-dd ");
string where = " company= ' " + Session[ "company "].ToString().Trim() + " ' ";
where += "and convert(varchar(10),logdate,020)= ' " + day + " ' ";
if (e.Day.IsOtherMonth)
{
e.Cell.Controls.Clear();
}
else
{
//GetDr()通过分页存储过程返回一个SqlDataReader,参数(表,返回字段,排序字段,返回记录数,页码....,where语句)
SqlDataReader dr = comm.GetDr( "userlog ", "* ", "id ", 10, 1, 1, 1, where);
if (dr.HasRows)
{
while (dr.Read())
{
if (dr[ "Total "] != DBNull.Value && dr[ "Total "].ToString() != "0 ")
{
Label lbl = new Label();
lbl.Text = dr[ "Total "].ToString();
lbl.ForeColor = Color.Red;
e.Cell.Controls.Add(new LiteralControl( " <br> "));
e.Cell.Controls.Add(lbl);