Community discussion forum

Displaying an error message when no records are returned

  • 7 months ago
    Hi all, I have added a search function on my website today using Microsoft Access, by the use of select statements and all works fine. However, I am unsure of how to display an error message when there isnt any records found. Does anyone have an idea of how to do this? Many Thanks. James
    Post was edited on 07/04/2009 14:27:49 Report abuse
  • 7 months ago
    Hi all, I have added a search function on my website today using Microsoft Access, by the use of select statements and all works fine. However, I am unsure of how to display an error message when there isnt any records found. Does anyone have an idea of how to do this? Many Thanks. James
  • 7 months ago
    hi, Do you mean you dont know how to check that no results are returned? Si
  • 7 months ago
    Hi Si No sorry..I meant to say that on the page I have one textbox and one button. When you type in a valid query into the textbox it will redirect the user to a page listing all the possible matches for that query. But if you type something, which the database cannot find it comes up blank. So i was wandering if there was a way where I could have an error message saying that the results cannot be found. Thank you
  • 7 months ago
    Hiya, that is pretty much what i was asking, from what i understand this is what is happening. user enters a search term and hits search user is redirected to a page that shows results page searches the database but returns no records page just displays a blank result set if this is the case, then when you call the database, you should do a check to see if some records are returned. if not, then bounce them back to the search page with a message that no results could be returned. Si
  • 7 months ago
    Thank you for your reply Yes that is whats happening at the moment. I have tried to do a count but it comes up with a compilation error. I have tried various other things but I havent had no luck as of yet. I was wandering if you could help me with this. Many Thanks, James
  • 7 months ago
    ok, How are you returning the results? is it a dataset? if it is, then you can use if dsdata is nothing orelse if dsdata.tables.count <= 0 orelse dsdata.tables(0).rows.count <= 0 then ' no data returned else ' data returned end if If it is a datareader, then you can check the hasrows property. Si
  • 7 months ago
    Thank you..I was using a datalist to return the data. I changed the code to: If Datalist.Items.Count <= 0 Then Label1.Text = "No Matches Found - Please try again" Label1.Visible = "True" Else Label1.Visible = "False" Thank you so much for your help. James

Post a reply

Enter your message below

Sign in or Join us (it's free).

Want to stay in touch with what's going on? Follow us on twitter!