Monday, February 1, 2010

Default.aspx.cs

using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;
public partial class _Default : System.Web.UI.Page
{
SqlConnection connecotion = new SqlConnection("Data Source=.;Initial Catalog=liaotian;Integrated Security=True");
protected void Page_Load(object sender, EventArgs e)
{

}
protected void Timer1_Tick(object sender, EventArgs e)
{
connecotion.Open();
SqlDataAdapter Adapter = new SqlDataAdapter("select * from yonghu where zaixian='1'", connecotion);
DataSet set = new DataSet();
Adapter.Fill(set);
ListBox1.DataSource = set;
ListBox1.DataTextField = "name";//5~1-a-s-p-x
ListBox1.DataValueField = "name";
ListBox1.DataBind();

}
protected void Button1_Click(object sender, EventArgs e)
{
Application.Set("jilu",Application["jilu"] + "
" + Convert.ToString(Session["name"]) + "说:" + TextBox2.Text);
TextBox2.Text = "";
}

}