【问题标题】:Searching database using keyword that will display all subject from database that has the keyword使用关键字搜索数据库,将显示数据库中具有该关键字的所有主题
【发布时间】:2015-09-04 20:36:48
【问题描述】:

我正在创建一个系统,用于跟踪办公室的进出文档。用户应该能够查看报告或记录。我创建了一个简单的文本框作为搜索工具。搜索过程应允许用户使用关键字选择 datagridview。

示例:如果用户搜索关键字为“Book”的记录,则应显示其中包含单词“book”的主题。 示例:关键字:书

     displays in datagridview: the book of secrets
                               book shelf
                               record book

不分大写或小写。有点像谷歌

我尝试创建一个搜索过程,但它只显示确切的单词而不是带有单词“Book”的语句

这是我的代码

Try
            connection.Open()

            Dim query As String
            query = "select id,Type_of_Document,Items,Received_From,Received_Date,Remarks,Marginal_Note,Referred_To,Referred_Date,Action_Taken  from tracker.recordtracker where Items = '" & srchtbx.Text & "'"
            Command = New MySqlCommand(query, connection)
            adapter.SelectCommand = command
            adapter.Fill(DataSet)
            bind.DataSource = DataSet
            DataGridView1.DataSource = bind
            adapter.Update(DataSet)
            connection.Close()
        Catch ex As Exception
            MsgBox(ex.Message)
        Finally
            connection.Dispose()
        End Try

感谢任何帮助

【问题讨论】:

    标签: mysql datagridview search-engine


    【解决方案1】:

    在你的 where put % like this

    where Items Like '%" & srchtbx.Text & "%' 
    

    【讨论】:

    • 谢谢..我确实能够修复它,我在 sql 中查找了 LIKE..将查询更改为 "select id,Tracking_No,Type_of_Document,Section,Incoming_Outgoing,Subject_For,Subject_From,Subject_Date,Subject,Received_From,Received_Date,Remarks,Marginal_Note,Referred_To,Referred_Date,Action_Taken from tracker.recordtracker where Subject LIKE '%" & srchtbx.Text & "%'"
    • 我忘了把 = 改成 like 。对不起
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-08-21
    • 2014-09-02
    相关资源
    最近更新 更多