62,074
社区成员
发帖
与我相关
我的任务
分享
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
conn.Open();
string s = Request.QueryString["keyword"].ToString();
string sql = "select * from News where newsTitle like '%" + s + "%' or newsContent like '" + s + "%' order by newsId desc";
SqlDataAdapter da = new SqlDataAdapter(sql, conn);
DataSet ds = new DataSet();
da.Fill(ds, "a");
int count = ds.Tables["a"].Rows.Count;
this.labMsg.Text = "搜索到:" + count + "记录";
dlNews.DataSource = ds.Tables["a"];
dlNews.DataBind();
conn.Close();
}
}
string s = Request.QueryString["keyword"].ToString().Repleace("'","''");