2011-04-02 65 views
1

嗨在我的主页上我有一个搜索框中包含一个文本框(TextBox1.Text)和一个按钮(Button1_Click)两个asp控件。通过文本框和按钮搜索mysql数据库并将输出重定向到另一页

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

到目前为止:

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? 
} 

}

其他的事情我尝试搞清楚的是我怎么会发送到另一个页面,以查看列表视图。

回答

相关问题