c#站内搜素代码

来源:百度知道 编辑:UC知道 时间:2024/05/29 14:42:39
谁有c#站内搜素代码告诉下 实在是着急
想了好多天也没什么头绪 DB里面方法有查询方法
怎么来运用啊
就是站内搜索文章
一个textBox(写要输入的文字)
一个Button(搜素按钮) 查询就在边上显示
查询数据库里面的数据 我知道要用到select * from table where title like '%***%' or wh like '%***%'
这个句子 我的DB里面也有public bool ExecuteReade(string sql)
{
SqlConnection conn = DB.getconn();
bool flag = false;
conn.Open();
SqlCommand cmd = new SqlCommand(sql, conn);
SqlDataReader sdr = cmd.ExecuteReader();
if (sdr.HasRows)
{
flag = true;
}
sdr.Close();
conn.Close();
return flag;
谁能告诉我怎么做啊 真迷糊了 我才学c#没多久 我的分用光了....不好意思.
gridview,repeater哪个都可以 最好是repeater

假设你是要从Textbox中获取关键字(比如姓),然后在数据库中的Student表中查询姓为文本框中文字的人,最后将人显示在DataGridView中。
using System;
using System.Data;
using System.Configuration;
using System.Collections;
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;
using System.Web.UI.MobileControls;
using System.Collections.Generic;

namespace WebApplication1
{
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{

}

public class Student
{
private string _Name;

public string Name
{
get { return _Name; }
set { _Name = value; }
}