删除关键字计数VB.net

时间:2013-10-10 06:10:32

标签: vb.net keyword-search

我有关于此计数的问题关键字后出现那些东西

此处代码

Public Sub searchayumiKn()
    Dim myKeyWords() As String = TChat.Text.Split(" "c)
    Dim mySQLQuery As String = "SELECT AIRes FROM T_GKnowledge WHERE "
    Dim KeyWordCount As Integer

    For KeyWordCount = 0 To myKeyWords.Length - 1
        Dim strKeyParameter As String = String.Format("@Param{0}", KeyWordCount)
        Dim strWhereClause As String

        If KeyWordCount = 0 Then
            strWhereClause = String.Format("Keyword LIKE {0}", strKeyParameter)
        Else
            strWhereClause = String.Format(" OR Keyword LIKE {0}", strKeyParameter)
        End If
        mySQLQuery &= strWhereClause
        cmdhikari.Parameters.AddWithValue(strKeyParameter, String.Format("{0}{1}{0}", "%", myKeyWords(KeyWordCount)))
    Next

    With cmdhikari
        .CommandText = mySQLQuery
        .Connection = conayumi
    End With

    Try
        dthikari = New DataTable
        dahikari.Fill(dthikari)
        answers.DataBindings.Add("text", dthikari, "AIRes", True)
    Catch ex As Exception
        MsgBox(ex.Message, MsgBoxStyle.Critical, "Caution")
    End Try
    KeyWordCount = 0
    TChat.Clear()
    Return
End Sub

得到错误@param bla“。有人可以删除此计数吗? 我只需要原始的数据记录。每次都不算数。只是不使用计数。所以自由记录

1 个答案:

答案 0 :(得分:0)

退出本声明

Dim strKeyParameter As String = String.Format("@Param{0}", KeyWordCount)
Dim strWhereClause As String

它使重复声明具有相同的参数

希望可能有用

问候 Ade Nurhuda