Can you please help me in my problem regarding in using Listview in vb.net. I can manipulate some flow like searching and selecting data coming in database (SQL) but my problem is that i need a message thtat will pop up that there is no particular data in the database where ever i find a data.

I have my "search button" that triggers to display any record. But if there is no record there is no message that will show that there is no record found. I dont knowhow to code it so please help me..

Thanks. Hope that you will help me. Godbless.

haha just kidding, it depends on how your querying the data for me to say exactly how to check.

If your results are being returned to a DataSet/DataTable, you can check the row count and if it is zero, you can display the message.

If myTable.Rows.Count = 0 Then MessageBox.Show("Better luck next time")

If your using something like ExecuteScalar, a DataReader etc you may need to check that the object is not null.

hello,
you didn't provide accurate information in order for me to reply you but i will try to give you some idea, now this is with a data reader.

Dim dr As OleDbDataReader
 If dr.HasRows Then
               'Do actions here!
            Else
                MessageBox.Show("No records forund", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
END IF

Regards.

dim rows as listviewitem
rows = 0
If (Row > 0) Then
'condition
Else
messagebox.show("there is no record")

this can also work for you

This article has been dead for over six months. Start a new discussion instead.