分类:
2009-11-23 21:40:39
按日期查询
新建一HiddenField用于存储Session值
HiddenField1.Value = Session["IDUSE"].ToString();
新建一Datalist用于存储该用户写的日志的标题
protected void getdata()
{
string time1 = CodefanCalendar1.Text;
string time2 = CodefanCalendar2.Text;
string IDUSE = HiddenField1.Value;
myco = new MySqlConnection(strconn);
myco.Open();
mycomm = new MySqlCommand("RizhichabeaTime", myco);
mycomm.CommandType = CommandType.StoredProcedure;
MySqlParameter[] para = new MySqlParameter[]{
new MySqlParameter("@time1_",MySqlDbType.DateTime),
new MySqlParameter("@time2_",MySqlDbType.DateTime),
new MySqlParameter("@IDUSE_",MySqlDbType.VarChar,20)
};
para[0].Value = time1;
para[1].Value = time2;
para[2].Value = IDUSE;
mycomm.Parameters.AddRange(para);
MySqlDataAdapter myda = new MySqlDataAdapter();
myda.SelectCommand = mycomm;
DataSet ds = new DataSet();
myda.Fill(ds);
DataList1.DataSource = ds;
DataList1.DataBind();
}
protected void Button1_Click(object sender, EventArgs e)
{
getdata();
}