Print Page | Close Window

ASP/Access Data Retrieval

Printed From: Web Wiz Forums
Category: General Discussion
Forum Name: Classic ASP Discussion
Forum Description: Discussion on Active Server Pages (Classic ASP).
URL: https://forums.webwiz.net/forum_posts.asp?TID=8713
Printed Date: 01 April 2026 at 1:00am
Software Version: Web Wiz Forums 12.08 - https://www.webwizforums.com


Topic: ASP/Access Data Retrieval
Posted By: Garrett1226
Subject: ASP/Access Data Retrieval
Date Posted: 09 January 2004 at 1:38pm

I am fairly new to ASP and have just recently started projects to take advantage of its functionality.  I am creating a new web form with which my customers can enter their ZIP codes and from their response I have an ASP engine that queries an Access database for the results.

I have developed a good connection to the DB.  The table includes: ID (key) | NAME | Address | EMAIL.  How would I word the retrieval of the entire row of information?  How do I word the ZIP Code-To-key scripting?

Thanks for any help you can give.



-------------
Garrett Miller



Replies:
Posted By: Semikolon
Date Posted: 09 January 2004 at 1:48pm

you could try reading the database tutorials from bruce if you want to learn how to connect to a database and show/delete/update the data..

what do you mean with zip code-to-key?



Posted By: Garrett1226
Date Posted: 09 January 2004 at 1:58pm

Sorry for the confusion:

I read the tutorials and that was how I figured out how to connect to the database.  From the tutorials, I learned how to return all the values in the Access database using the  DO WHILE - LOOP command.  I can do that fine, I have just not been able to find any literature explaining how to retrieve one row of information from a table.

To be more specific:  I have an HTML form that allows a user to enter their Zip Code.  That form posts to an ASP page.  I was going to use SELECT CASE statements to list all the possibilities for ZIP Code entries for my state. (have already used this method on another project and had good results). 

Using this setup, how can I reference "example" Zip Code: 65101 to automatically pull all the information from the row that has the key value of 2?  Within row 2 I have columns NAME | ADDRESS | FAX | EMAIL

Thanks for your quick response.



-------------
Garrett Miller


Posted By: Semikolon
Date Posted: 09 January 2004 at 2:06pm

you should use the zip in the key, or you will have to create if/case lines for each zip..

 

to get only one row use this sql string

strSQL = "SELECT * FROM table WHERE ID = " & integersource

 

integersource is where you get the zip or whatever you want to use from.. for example Request.Form("ZIP") if you are using the POST method..



Posted By: Garrett1226
Date Posted: 09 January 2004 at 4:32pm

Thanks for your help.  I ended up with the following to resolve all the queries:

Example:

Case 64422, 64430, 64447, 64469, 64474, 64490, 64494, 64497
 'Dekalb County
 
  strSQL = "SELECT * FROM CropAgents WHERE ID = 1"
  Set rsCropAgents = Server.CreateObject("ADODB.Recordset")
  rsCropAgents.Open strSQL, adoCon
  response.write("<left><br>")
  response.write("<b>" & rsCropAgents("NAME") & "</b>" & "<br>")
  response.write(rsCropAgents("ADDRESS") & "<br>")
  response.write(rsCropAgents("CITY") & "<br>")
  response.write(rsCropAgents("ZIP") & "<br>")
  response.write("Phone Number: " & rsCropAgents("PHONE") & "<br>")
  response.write("Fax Number: " & rsCropAgents("FAX") & "<br>")
  response.write("Email Address: " & rsCropAgents("EMAIL") & "<br>")

 

Thanks again for your quick responses.

-------------
Garrett Miller


Posted By: Semikolon
Date Posted: 09 January 2004 at 5:16pm

that wasnt a request for help right?

but you should not use <left> and <br>.. thats not good xHTML..
use <div align="left"></div> and <br /> instead..
but this isnt really nessesary.. its just that in the future, the browsers may not understand it if youre not using xHTML by the rules.. so its recommended to start learning it at once..




Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.08 - https://www.webwizforums.com
Copyright ©2001-2026 Web Wiz Ltd. - https://www.webwiz.net