从无法运行的查询中选择

时间:2018-08-23 15:30:53

标签: vb.net ms-access

我只想在我的数据库中搜索数据,但是即使我在文本框和comboBox中输入的数据具有正确的数据,它也无法正常显示else语句。应该是其他

Private Sub Button12_Click(sender As Object, e As EventArgs) Handles Button12.Click
    searchWanted()
End Sub 

Public Sub searchWanted()
    Dim connString111 As String = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=bin\Debug\record.accdb"
    MyConn111 = New OleDbConnection
    MyConn111.ConnectionString = connString111
    Try
        Dim mySQLCommand As New OleDbCommand("select from * mostwanted where FIRSTNAME = @b0 and MIDDLENAME = @b1 and LASTNAME = @b2 and QLFR = @b3", MyConn111)
        mySQLCommand.Parameters.AddWithValue("@b0", FIRSTNAMETextBox.Text)
        mySQLCommand.Parameters.AddWithValue("@b1", MIDDLENAMETextBox.Text)
        mySQLCommand.Parameters.AddWithValue("@b2", LASTNAMETextBox.Text)
        mySQLCommand.Parameters.AddWithValue("@b3", QLFRComboBox.SelectedItem)
        Dim da111 As New OleDbDataAdapter(mySQLCommand)
        Dim table As New DataTable()
        If table.Rows.Count() > 0 Then
            MessageBox.Show("This Person is Wanted")

            Dim picturedata As [Byte]() = table.Rows(0)(15)
            Using ms As New MemoryStream(picturedata)
                PHOTOPictureBox.Image = Image.FromStream(ms)
            End Using
        Else
            MessageBox.Show("This Person is CLEAN")
        End If
    Catch ex As Exception
        MessageBox.Show(ex.Message)
    End Try
End Sub

0 个答案:

没有答案