C# 通过文本框和按钮搜索mysql数据库,并将输出重定向到另一个页面

C# 通过文本框和按钮搜索mysql数据库,并将输出重定向到另一个页面,c#,asp.net,mysql,sql,html,C#,Asp.net,Mysql,Sql,Html,您好,在我的主页上,我有一个搜索框,其中包含一个文本框(TextBox1.Text)和一个按钮(Button1_-Click)两个asp控件 我试图找出如何搜索我的数据库和检索可能类似的内容,我有一个用户表,我想搜索用户,但拼写可能是错误的,所以如果拼写是错误的,我如何仍然返回某人,如果你知道我的意思吗 到目前为止: protected void Button1_Click(object sender, EventArgs e) { // Search Users String

您好,在我的主页上,我有一个搜索框,其中包含一个文本框(TextBox1.Text)和一个按钮(Button1_-Click)两个asp控件

我试图找出如何搜索我的数据库和检索可能类似的内容,我有一个用户表,我想搜索用户,但拼写可能是错误的,所以如果拼写是错误的,我如何仍然返回某人,如果你知道我的意思吗

到目前为止:

protected void Button1_Click(object sender, EventArgs e)
{
    // Search Users
    String Search = TextBox1.Text;
    using (OdbcConnection cn = new OdbcConnection("Driver={MySQL ODBC 3.51 Driver}; Server=localhost; Database=gymwebsite2; User=x; Password=x;"))
    {
    cn.Open();
    using (OdbcCommand cmd = new OdbcCommand("SELECT * FROM User WHERE FirstName LIKE '%"+ Search +"%';", cn))
    //not sure if this is correct, will it return anything that is similar to what is typed?       
    Response.Redirect("Search.aspx");
    // dont know how to send this to a listview on another page? 
}
}

我想弄清楚的另一件事是如何将它发送到另一个页面,以便在listview中查看

查看或。

查看或