Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/vb.net/17.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Vb.net 无法在listview中显示数据库中的匹配数据_Vb.net - Fatal编程技术网

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

Vb.net 无法在listview中显示数据库中的匹配数据,vb.net,Vb.net,我试图搜索一个路径,散列一个文件,并在textbox4中显示当前散列,同时搜索ms数据库中的散列,如果是,则显示从数据库到列表视图的相应信息。一切正常,只是它没有添加与列表视图匹配的数据。您需要将listviewitem添加到listview项目集合我添加了ListView1.items.Additm,但它仍然没有显示匹配的项目,我必须仍然缺少一些内容。cheers.strg=SELECT*FROM Table1 WHERE MD5='&TextBox4.Text首先替换为:'strg=SELE

我试图搜索一个路径,散列一个文件,并在textbox4中显示当前散列,同时搜索ms数据库中的散列,如果是,则显示从数据库到列表视图的相应信息。一切正常,只是它没有添加与列表视图匹配的数据。

您需要将listviewitem添加到listview项目集合我添加了ListView1.items.Additm,但它仍然没有显示匹配的项目,我必须仍然缺少一些内容。cheers.strg=SELECT*FROM Table1 WHERE MD5='&TextBox4.Text首先替换为:'strg=SELECT*FROM Table1 WHERE MD5=@MD5'Arun Sharma您是一个传奇,它现在正在工作如果没有空的Try/Catch,代码将能够报告问题
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()