无法在listview中显示数据库中的匹配数据

时间:2014-05-04 02:23:48

标签: vb.net

Dim i As Integer
    Dim itm As ListViewItem
    Dim str(7) As String
    Dim provider As String
    Dim dataFile As String
    Dim connString As String
    Dim Errors As String

    provider = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source ="
    dataFile = "Trojans.accdb"
    connString = provider & dataFile
    myConnection.ConnectionString = connString
    Errors = ""

    For i = 1 To 4
        Dim di As New DirectoryInfo(path(i))
        For Each File In System.IO.Directory.GetFiles(path(i), "*", SearchOption.AllDirectories)
            Dim fs As New FileInfo(File)

            Label4.Text = fs.FullName
            TextBox4.Text = _Info.mdsc(fs.FullName).ToUpper
            Try
                Using myConnection As OleDbConnection = New OleDbConnection(connString)
                    myConnection.Open()
                    Dim strg As String
                    strg = "SELECT * FROM Table1 WHERE MD5='" & TextBox4.Text
                    Using cmd2 As OleDbCommand = New OleDbCommand(strg, myConnection)
                        cmd2.Parameters.AddWithValue("MD5", TextBox4.Text)
                        Using dr As OleDbDataReader = cmd2.ExecuteReader
                            If dr.HasRows Then
                                dr.Read()
                                If TextBox4.Text = dr("MD5").ToString Then
                                    Dim show As String = "SELECT * FROM Table1 WHERE MD5='" & TextBox4.Text
                                    Label10.Text = Label10.Text + 1
                                    str(0) = fs.Name
                                    str(1) = show
                                    str(2) = _Info.getSHA1Hash(fs.FullName)
                                    str(3) = _Info.getSHA256Hash(fs.FullName)
                                    str(4) = _Info.GetCRC32(fs.FullName)
                                    str(5) = fs.FullName
                                    str(6) = NativeMethods.FormatBytes(fs.Length) & " (" & fs.Length & " bytes)"
                                    itm = New ListViewItem(str)
                                    ListView1.Items.Add(itm) 'Added this but still no go
                                    MsgBox("Found: " & dr("MD5") & "!")
                                Else
                                    MsgBox("Error")
                                End If
                            Else
                                MsgBox("Error")
                            End If
                        End Using
                    End Using
                End Using
            Catch ex As Exception
                'MsgBox(ex.ToString)
            End Try
            Label5.Text += 1
            If Label5.Text < ProgressBar1.Maximum Then
                ProgressBar1.Value = Label5.Text
            End If
        Next
    Next

    myConnection.Close()

我正在尝试搜索路径,散列文件并在textbox4中显示当前散列,同时在ms数据库中搜索散列,以及它们是否显示从数据库到列表视图的相应信息。除了没有添加与列表视图匹配的数据外,一切正常。

0 个答案:

没有答案