Quantcast
Viewing all articles
Browse latest Browse all 27220

Display Msgbox if no records returned from select statement in VB.NET

Hi, how and where do I add a Msgbox in the following code to alert the user that there is no Match
thanks
Code:

    Private Sub BtnSearch_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSearch.Click
        Dim ds As New DataSet
        Dim connectionstring As String
        connectionstring = "provider = Microsoft.ACE.OLEDB.12.0;Data Source=C:\Users\Amaechi\Documents\Databases\Humanresouces.accdb;"
        'your select command could select for example 2 fields
        'SELECT fieldName1, fieldName2 FROM tableName
        Dim query As String = String.Format("SELECT EmpID,LastName,FirstName FROM EmployeeTbl where LastName = '{0}'", txtLastName.Text)
        Dim dataAdapter As New OleDb.OleDbDataAdapter(query, connectionstring)
        dataAdapter.Fill(ds, "EmployeeTbl")
        DataGridViewCheckEmployee.DataSource = ds.Tables(0) 
    End Sub


Viewing all articles
Browse latest Browse all 27220

Trending Articles