Hi everyone.. i don't know how to display NO RECORD FOUND in msgbox..

here is my codes

Private Sub btngo_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btngo.Click
        open_con()
        sqlsearch = "Select *from tblborrower where ID_no=" & txtidno.Text & ""
        cmd = New OleDbCommand(sqlsearch, con)
        dr = cmd.ExecuteReader

        While dr.Read
            txtidno.Text = dr("ID_No")
            txtname.Text = dr("Borrower_Name")
            cbocourse.Text = dr("Course")
            txtcontactno.Text = dr("Contact_No")
            txtaddress.Text = dr("Address")
        End While

        dr.Close()
        dr = Nothing
        cmd = Nothing
        sqlsearch = Nothing
        con.Close()
    End Sub

i don't know where to put the msgbox..

please help me

sqlsearch = ("Select *from tblborrower where ID_no='" & txtidno.Text & "'",con)


i think the problem with your codes was the part of sql command.. :)but i'm not pretty sure about it! you can try changing it with the above code i placed.. hope it can help.

Instead of while loop, better use abn if block. Because you want to go through the code only ones.
And there you can put an else block, which will be fired if no data will be found:

If dr.Read Then
	txtidno.Text = dr("ID_No")
	txtname.Text = dr("Borrower_Name")
	cbocourse.Text = dr("Course")
	txtcontactno.Text = dr("Contact_No")
	txtaddress.Text = dr("Address")
Else
	MessageBox.Show("No data found.")
End If

@ Mitja Bonca: thank you for your help!! you answered my question..

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.