PDA

View Full Version : Query to Access database thru .ASP using SQL



JeratBP
21 Mar 2007, 10:04 AM
If this works when I'm done, I'll be glad to share the code with everyone. Here's my search page below.

Running Events (http://www.baileysphotoofnorfolk.com/kale/search%20box.html)

The Action on this page/form is set to 'getresults.asp'. The database is 'mydatabase.mdb'. I need the Sql search to go into the database, based on the search terms entered. The results page will show a thumbnail(s) of the picture of the racer. My current package with the hosting company doesn't include support for PHP.

Code for 'getresults.asp' from my hosting company:

<html>
<title>Database query using ASP</title>
<body bgcolor="FFFFFF">
<h2>Query table <b>Products</b> with ASP</h2>
<%
Set dbaseConn = Server.CreateObject("ADODB.Connection")
dbaseConn.Open "DRIVER={Microsoft Access Driver (*.mdb)};DBQ=" & Server.Mappath("\db\mydatabase.mdb") & ";"
SQLQuery = "SELECT * FROM PRODUCTS"
Set RS = dbaseConn.Execute(SQLQuery)
%>
<%
Do While Not RS.EOF
%>
<%=RS("name")%>, <%=RS("description")%>, <%=RS("price")%> DM
<p>
<%
RS.MoveNext
Loop
RS.Close
Set RS = Nothing
dbaseConn.Close
Set dbaseConn = Nothing
%>
</body>
</html>


Any feedback or suggestions are appreciated.
Thank you

JeratBP
22 Mar 2007, 09:50 AM
Possibly resolved issue, see link to the tutorial:

http://authors.aspalliance.com/glenncook/searchcode.asp

I'll find out tonight if it resolves my issue.