0

我有关于这个计数关键字的问题之后出现的东西

这里代码

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”。任何人都可以删除这个计数吗?我只需要原始数据记录。不是每次都计数。只是不使用计数。所以自由记录

4

1 回答 1

0

为此声明搬出

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

它使重复声明相同的参数

希望可能有用

问候阿德努尔胡达

于 2013-11-12T11:07:40.543 回答