Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. No results.. please try again message

No results.. please try again message

Scheduled Pinned Locked Moved ASP.NET
csharpasp-netdatabasevisual-studio
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • D Offline
    D Offline
    DaithiBoo
    wrote on last edited by
    #1

    Hi there.. :) im workin on a website at the moment in asp.net, using vb.net, in the visual studios 2008 IDE! i just wish to add an extra feature and hopefully someone out there might be able to help. I have a button that reads the values of 5 radio buttons in a radiobutton list, then queries the database, returning results based on the values selected. If no value is returned i wish to display a message saying "No Results this time, please search again" or something to that effect. Im not sure how to do this. here is the code i have behind the button.. Please advise. Protected Sub btnSuggest_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnSuggest.Click Dim myConnection As SqlConnection Dim myCommand As SqlCommand Dim dr As SqlDataReader Dim varBatteryLifeQ As String = "" Dim varMemoryQ As String = "" Dim varRam As String = "" Dim varScreenSize As String = "" Dim varWebcam As String = "" myConnection = New SqlConnection("Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\Database.mdf;Integrated Security=True;User Instance=True") myConnection.Open() varBatteryLifeQ = RadioButtonList1.SelectedValue.ToString varMemoryQ = RadioButtonList2.SelectedValue.ToString varRam = RadioButtonList3.SelectedValue.ToString varScreenSize = RadioButtonList4.SelectedValue.ToString varWebcam = RadioButtonList5.SelectedValue.ToString myCommand = New SqlCommand("Select * From LPU400 Where BatteryLife = '" + varBatteryLifeQ + "' AND Memory = '" + varMemoryQ + "' AND RAM ='" + varRam + "' AND ScreenSize ='" + varScreenSize + "' AND Webcam ='" + varWebcam + "'", myConnection) SqlDataSource2.SelectCommand = "Select * From LPU400 Where BatteryLife = '" + varBatteryLifeQ + "' AND Memory = '" + varMemoryQ + "' AND RAMQ ='" + varRam + "' AND ScreenSize ='" + varScreenSize + "' AND Webcam ='" + varWebcam + "'" SqlDataSource2.DataBind() dr = myCommand.ExecuteReader() While dr.Read() End While dr.Close() myConnection.Close() End Sub Thanks in advance, Daithi

    D 1 Reply Last reply
    0
    • D DaithiBoo

      Hi there.. :) im workin on a website at the moment in asp.net, using vb.net, in the visual studios 2008 IDE! i just wish to add an extra feature and hopefully someone out there might be able to help. I have a button that reads the values of 5 radio buttons in a radiobutton list, then queries the database, returning results based on the values selected. If no value is returned i wish to display a message saying "No Results this time, please search again" or something to that effect. Im not sure how to do this. here is the code i have behind the button.. Please advise. Protected Sub btnSuggest_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnSuggest.Click Dim myConnection As SqlConnection Dim myCommand As SqlCommand Dim dr As SqlDataReader Dim varBatteryLifeQ As String = "" Dim varMemoryQ As String = "" Dim varRam As String = "" Dim varScreenSize As String = "" Dim varWebcam As String = "" myConnection = New SqlConnection("Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\Database.mdf;Integrated Security=True;User Instance=True") myConnection.Open() varBatteryLifeQ = RadioButtonList1.SelectedValue.ToString varMemoryQ = RadioButtonList2.SelectedValue.ToString varRam = RadioButtonList3.SelectedValue.ToString varScreenSize = RadioButtonList4.SelectedValue.ToString varWebcam = RadioButtonList5.SelectedValue.ToString myCommand = New SqlCommand("Select * From LPU400 Where BatteryLife = '" + varBatteryLifeQ + "' AND Memory = '" + varMemoryQ + "' AND RAM ='" + varRam + "' AND ScreenSize ='" + varScreenSize + "' AND Webcam ='" + varWebcam + "'", myConnection) SqlDataSource2.SelectCommand = "Select * From LPU400 Where BatteryLife = '" + varBatteryLifeQ + "' AND Memory = '" + varMemoryQ + "' AND RAMQ ='" + varRam + "' AND ScreenSize ='" + varScreenSize + "' AND Webcam ='" + varWebcam + "'" SqlDataSource2.DataBind() dr = myCommand.ExecuteReader() While dr.Read() End While dr.Close() myConnection.Close() End Sub Thanks in advance, Daithi

      D Offline
      D Offline
      Dinesh Mani
      wrote on last edited by
      #2

      Before you proceed with dr.Read() check if dr.HasRows. If yes proceed to read, else put "No Results this time, please search again" in a label or some other place holder. HTH!

      D 1 Reply Last reply
      0
      • D Dinesh Mani

        Before you proceed with dr.Read() check if dr.HasRows. If yes proceed to read, else put "No Results this time, please search again" in a label or some other place holder. HTH!

        D Offline
        D Offline
        DaithiBoo
        wrote on last edited by
        #3

        ya that did it! thanks a million for your help! very much appreciated!

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups