Home arrow ASP arrow Page 4 - Calorie Counter Using WAP and ASP

Calorie Counter Using WAP and ASP

Many people are more conscious of what they eat than ever before. (I count myself as a member of that club). The biggest challenge faced by many in the quest for a healthier lifestyle is the ubiquitous “lack of time” excuse. To help out, I have created a simple WAP application that allows for one to search for different foods and get related nutritional information, based on data from the American Diabetes Association. In this article, I’ll go over the creation of the application, and in the process, make you a little bit more health conscious.

Author Info:
By: Tim Haight
Rating: 5 stars5 stars5 stars5 stars5 stars / 62
February 23, 2004
  1. · Calorie Counter Using WAP and ASP
  2. · Hosting
  3. · Index.wml
  4. · Application Deconstruction: Search.asp

print this article

Calorie Counter Using WAP and ASP - Application Deconstruction: Search.asp
(Page 4 of 4 )

This file contains the DSN-less connection, a SQL query, and the results. Note that the SQL query uses a like clause. This allows you to enter part of a food name and get back every food that contains that search string.  This feature is useful for any type of SQL query where the exact search string is vague.

<%@ Language = "JScript"; %><% Response.ContentType = "text/vnd.wap.wml";
%><?xml version="1.0"?>
<!-- #include file="adojavas.inc" -->

   <card id="card1" title="Food Results">
         Food Search Results<br/>

// dsn-less connection to food.mdb

   conn = Server.CreateObject("ADODB.Connection");
   rs   = Server.CreateObject("ADODB.Recordset");

   conn.Open("DRIVER={Microsoft Access Driver (*.mdb)};DBQ=" +
             Server.MapPath("Food.mdb") + ";");

// create a string to hold the SQL query
   sqlQuery = "SELECT * FROM tblFoods where Description like '%" + Request.QueryString("Food") + "%' ORDER BY DESCRIPTION";

// execute the query on the database
   rs.Open(sqlQuery, conn, adOpenForwardOnly, adLockReadOnly, adCmdText);

   while (!rs.EOF)
      Response.Write("Description: ");
      Response.Write(rs("Description") + "<br/>");
      Response.Write("Serving: ");
      Response.Write(rs("Unit") + "<br/>");
      Response.Write("Fat: ");
      Response.Write(rs("Fat") + "<br/>");
      Response.Write("Calories: ");
      Response.Write(rs("Calories") + "<br/>");
      Response.Write("Carbs: ");
      Response.Write(rs("Carb") + "<br/>");
      Response.Write("Cholesterol: ");
      Response.Write(rs("Cholesterol") + "<br/>");

After these files are uploaded to the hosting server, you should be able to view them with any WAP enabled device, emulator, or browser. Now, you can’t use the “well, I didn’t know that the hamburger had 700 calories” excuse. Have fun, and stay healthy! 

DISCLAIMER: The content provided in this article is not warranted or guaranteed by Developer Shed, Inc. The content provided is intended for entertainment and/or educational purposes in order to introduce to the reader key ideas, concepts, and/or product reviews. As such it is incumbent upon the reader to employ real-world tactics for security and implementation of best practices. We are not liable for any negative consequences that may result from implementing any information covered in our articles or tutorials. If this is a hardware review, it is not recommended to open and/or modify your hardware.

blog comments powered by Disqus

- Central Scoreboard with Flash and ASP
- Calorie Counter Using WAP and ASP
- Creating PGP-Encrypted E-Mails Using ASP
- Be My Guest in ASP
- Session Replacement in ASP
- Securing ASP Data Access Credentials Using t...
- The Not So Ordinary Address Book
- Adding and Displaying Data Easily via ASP an...
- Sending Email From a Form in ASP
- Adding Member Services in ASP
- Removing Unconfirmed Members
- Trapping HTTP 500.100 - Internal Server Error
- So Many Rows, So Little Time! - Case Study
- XDO: An XML Engine Class for Classic ASP
- Credit Card Fraud Prevention Using ASP and C...

Watch our Tech Videos 
Dev Articles Forums 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us 
Weekly Newsletter
Developer Updates  
Free Website Content 
Contact Us 
Site Map 
Privacy Policy 

Developer Shed Affiliates


© 2003-2019 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap
Popular Web Development Topics
All Web Development Tutorials