private void button1_Click(Object sender,EventArgs e)
{
if(Page.IsValid)
{
string constr="database=rawRd;data source=(local);user id=sa;password=abc";
SqlConnection con=new SqlConnection(constr);
SqlCommand cmd=new SqlCommand();
cmd.Connection=con;
cmd.CommandText="select timepoint from [表名] where cardSN like '%"+this.textbox1.Text+"%'";
SqlDataAdapter da=new SqlDataAdapter();
da.SelectCommand=cmd;
DataTable dt=new DataTable();
try
{
da.Fill(dt);
}
catch{}
if(dt.Rows.Count==0)
{
Response.Write("<script language=javascript>alert('没有您需要的数据');</script>");
return;
}
this.datagrid1.DataSource=dt;
this.datagrid1.DataBind();
}
}
[此贴子已经被作者于2006-6-30 12:40:09编辑过]