ASP Forum
Help in Writing a Query
webmagi | Posted 4:06pm 14. July 2009 Server Time |

I need help in writing VB query script to search for an exact item such as id=10 in an Access database. I don't want it to come up with results such as 110, 210, etc.

I just need it to locate a record associated with a specfic number.

Thank you in advance!
ronmuir | Posted 0:28am 20. July 2009 Server Time |

Are you just looking for the SQL statement?

MYSQL = "SELECT * " &_
   "FROM myDatabase " &_
   "WHERE ID = 10"
webmagi | Posted 8:50am 22. July 2009 Server Time |

ronmuir, thank you for your reply. Actually what I am trying to accomplish is to do a query of a database using a search term in a URL.

ie. http://www.website/searchresults.asp?id=10

It would then search an Access database and come back with a single or exact result. It currently searches the database and comes back with several results that includes "10" such as "110", "100", "310" etc.

Thank you for your assistance.

Rand
GhostWolf | Posted 10:30am 30. July 2009 Server Time |

A minor modification of ronmuir's suggestion above:

mySQL = "select * from TheDataBase where ID=" + request.querystring("id")

Unless the ID field is alpha, then you'd use:

mySQL = "select * from TheDataBase where ID='" + request.querystring("id") + "'"
webmagi | Posted 3:44pm 20. August 2009 Server Time |

The suggestions above sound like what I need. I am somewhat of a novice when it comes to writing scripts. I have basically modified some code that I inherited but I can't quite figure out how this new code fits in. Is there a chance that I could email my current code to someone to see if anyone could lend me a hand? My email address is posted on my profile. Thank you!


Reply to Post Help in Writing a Query



Back to Forum Page