搜索按钮功能

时间:2013-07-25 16:40:15

标签: c# asp.net mysql

我的网页上有一个搜索按钮,它应该从DB中返回与输入的搜索词类似的主题名称,请帮我做...

这是我的C#代码

     protected void Button1_Click(object sender, ImageClickEventArgs e)
    {
        MySqlConnection connection = new MySqlConnection("server=localhost; database=e-learningsystem; uid=root; password=123;port=3307;");
        connection.Open();
        string srh = editbox_search.Type;
        try
        {
            MySqlCommand cmd = new MySqlCommand("SELECT * FROM subject WHERE Name='" + srh + "'", connection);

        }
        catch
        {
        }
    }

我的ASP代码

      <input name="editbox_search" class="editbox_search" id="editbox_search" 
              maxlength="80" type="text" 
              style="background-color: #99CCFF; margin-top: 0px;" runat="server" 
              enableviewstate="True" title="Search Courses:" clientidmode="Inherit" 
              dir="ltr" visible="True"/><asp:Button ID="Button1" 
              runat="server" Height="26px" Text="Go" Width="32px" />

1 个答案:

答案 0 :(得分:0)

谷歌搜索我找到了thisthis link

您还可以使用SqlDataSource