.net 通过数据表显示的文本文件的SQL查询

.net 通过数据表显示的文本文件的SQL查询,.net,.net,我有一个VB.NET应用程序,它使用ms Access数据库。但现在数据库被转换为文本文件,数据库的字段将通过数据表显示。问题是程序的一个功能工作不正常,在以前的格式中没有显示任何问题。这是一个查询函数myStr=SELECT ID,word FROM Words WHERE&myval&ORDER BY ID,[word]ASC。请帮帮我。该函数的代码如下所示 Function ShowWords(ByRef Mybox As ListView, ByVal myval As String,

我有一个VB.NET应用程序,它使用ms Access数据库。但现在数据库被转换为文本文件,数据库的字段将通过数据表显示。问题是程序的一个功能工作不正常,在以前的格式中没有显示任何问题。这是一个查询函数myStr=SELECT ID,word FROM Words WHERE&myval&ORDER BY ID,[word]ASC。请帮帮我。该函数的代码如下所示

Function ShowWords(ByRef Mybox As ListView, ByVal myval As String, Optional ByVal track As Integer = 0) As Boolean
        If track = 0 Then
            If Len(myval) = 1 Then myval = "len(word)>=1 and len(word)<=40 and left(word, " & Len(myval) & ")= '" & myval.Substring(0, 1) & "'" 'myval.Substring(1) & "'"
            If Len(myval) = 2 Then myval = "len(word)>=2 and len(word)<=45 and left(word, " & Len(myval) & ")= '" & myval.Substring(0, 2) & "'"
            If Len(myval) = 3 Then myval = "len(word)>=3 and len(word)<=50 and left(word, " & Len(myval) & ")= '" & myval.Substring(0, 3) & "'"
            If Len(myval) = 4 Then myval = "len(word)>=4 and len(word)<=65 and left(word, " & Len(myval) & ")= '" & myval.Substring(0, 4) & "'"



 Try
                lvWords.Items.Clear()
                If myval = "" Then
                    Exit Function
                End If
                Dim myStr As String = Nothing
                myStr = "SELECT ID, word FROM Words WHERE " & myval & " ORDER BY id, [word] ASC"

                Dim objCmd As New OleDbCommand(myStr, objConn)
                Dim rs As OleDbDataReader = objCmd.ExecuteReader
                If rs.HasRows Then
                    Dim xItem As ListViewItem
                    Do While rs.Read
                        xItem = Mybox.Items.Add(rs("ID"), IIf(IsDBNull(rs("word")), "", rs("word")), "")
                    Loop
                Else
                    ShowWords = False
                    Exit Function
                End If
            Catch ex As Exception
                MsgBox(ex.Message)
                ShowWords = False
                Exit Function
            End Try
        ElseIf track = True Then
            ShowWords = track
            Exit Function
        End If
        ShowWords = True
    End Function

非常感谢您的更正。ID在access DB中是整数数据类型吗?如果是这样的话,当您将文本文件的格式转换为数据表时,您是否保留了该类型?如果您包含datatable代码并标记此VB.NET,则会有所帮助。是的,它将使用ID转换为整数。您没有真正解释uou的具体问题。请你详细介绍一下好吗。谢谢