View Single Post
  #4 (permalink)  
Old May 14th, 2014, 09:34 AM
Imar's Avatar
Imar Imar is offline
Wrox Author
Points: 72,055, Level: 100
Points: 72,055, Level: 100 Points: 72,055, Level: 100 Points: 72,055, Level: 100
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,086
Thanks: 80
Thanked 1,587 Times in 1,563 Posts
Default

You need to do something with the results from the command. Currently, you loop over the data and output it to the console which isn't all that useful in a web application.

You need to add some if logic that alerts the message whenever some row in your data set matches your criteria. I think, but that's only a wild guess as I am still unsure what you're trying to accomplish) that you may need a WHERE clause for a product ID in your SQL statement. Then you can read your data and inside the while (dr.Read()) call check the return value and if it matches some condition then output your alert. E.g.:

Code:
while (rdr.Read())
                {
  if (rdr[0].ToString == "Whatever you're cheking"))
  {
     string message = "Limit stock has been reached!";
                 ScriptManager.RegisterStartupScript(page, page.GetType(), "err_msg", "alert('" + message + "');", true);
  }
                }
Hope this helps,

Imar
__________________
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Follow me on Twitter

Author of Beginning ASP.NET 4.5 : in C# and VB, Beginning ASP.NET Web Pages with WebMatrix
and Beginning ASP.NET 4 : in C# and VB.
Did this post help you? Click the button below this post to show your appreciation!
Reply With Quote