Hi Folks,
I'm pretty green when it comes to ASP, so I'm hoping someone can help me out.
I'm putting archived articles from a sustainable agriculture magazine onto a website and I want folks to be able to search the articles by various criteria.
You can try it at:
http://www.tilthproducers.org/journalportalNEWasp.htm
The articles are stored in an Access database. So far it works if the search is for the year of the the article, the year being stored in the table in a column formatted as "number".
I'm working on the "search by subject" part now and it's not working. It's virtually the same code as for the "search by year", the only difference being the subject is stored in the table in a column formatted as "text". Some of the subjects are one word such as "crops" or two or three words such as "Farm Labor" or "Tools and Methods". I'm wondering if it's something to do with the spaces or just something stupid I'm not seeing.
HELP!
The code below generates the following error messages, either:
Microsoft OLE DB Provider for ODBC Drivers error '80040e14'
[Microsoft][ODBC Microsoft Access Driver] Syntax error (missing operator) in query expression 'Subject = Farm Labor'.
/tilthartsbysub.asp, line 38
or
Microsoft OLE DB Provider for ODBC Drivers error '80040e10'
[Microsoft][ODBC Microsoft Access Driver] Too few parameters. Expected 1.
/tilthartsbysub.asp, line 38
<%
'Create a variable to hold the region from previous page
dim holder
holder = Request ("artsub")
dim frmname 'Create a variable to hold the name of each form starting with 0
frmname = 0
'Create a connection to the database and a recordset to hold the data returned
Set articleConn = Server.CreateObject("ADODB.Connection")
articleFilePath = Server.MapPath("\_private\tiltharts.mdb")
articleConn.Open "Driver={Microsoft Access Driver (*.mdb)}; DBQ=" & articleFilePath & ";"
Set rs=Server.CreateObject("ADODB.Recordset")
sql = "SELECT * FROM Articles WHERE Subject = " & holder
'Open the recordset using the SQL statement and connection object above
rs.open sql, articleConn
'Write out the recordset returned until end of file reached
Response.write "<table border=1 BGCOLOR='#FFFFCC'>"
'Set up the table from here starting with R.W "<TR>...
'Write out the recordset returned until end of file reached
Response.write "<tr><td><h1>Articles with the Subject: " & holder & ":</h1>"
Response.write "<table border='1' width='488'><tr><th width='89'>READ<th width='143'>Date</td><th width='105'>Title</td><th width='123'>Author</td></tr>"
Do while not rs.eof
frmname = frmname+1
Response.write "<tr><td><form name = " & frmname & " action='tilthartsASP.asp'><input type='hidden' name='id' value=" & rs("Reference") & "><input type='submit' value='Read it!'></form></td>"
Response.write "<td>" & rs("Date") & "</td>"
Response.write "<td>" & rs("Title") & "</td>"
Response.write "<td>" & rs("Author") & "</td></tr>"
rs.MoveNext
Loop
'Finishes the script and closes the table
Response.write "</td></tr>"
'We are done, close and destroy objects
rs.Close
Set rs=Nothing
Set articleConn=Nothing
%> </table>