Click to See Complete Forum and Search --> : Search Engine


pao
04-07-2003, 01:13 PM
Hello to everybody!I am new in ASP.I want to make a search engine and I have written the following code and its coming out with errors! Can you check and tell me what is wrong; Thank you very much


<% @ Language=VBScript %>
<% Option Explicit %>
<!--#include virtual="/adovbs.inc" -->
<%

Dim adoCon, adoRec, adoConnectionString ,dbname
Dim dbRecordCount


Dim dbCurrent_day, dbID, dbPname, dbSurname, dbBlood_group, dbMarried_Single ,dbWard ,dbBed ,dbAdmission_day ,dbDischarge_day ,dbIllness ,dbSymptoms ,dbComments ,dbChronicle ,dbSmoking

' Get Current Category
cat = TRIM( Request( "cat" ) )
IF cat = "" THEN cat = "Home"

' Get Search Phrase
searchFor = TRIM( Request( "searchFor" ) )

dbname =Server.MapPath("fpdb/medicalDatabase.mdb")
adoConnectionString = "DRIVER={Microsoft Access Driver (*.mdb)};" &_
"DBQ=" & dbname & ";DefaultDir=;"
Set adoCon = Server.CreateObject("ADODB.Connection")
Set adoRec = Server.CreateObject("ADODB.Recordset")
adoCon.Open adoConnectionString
adoRec.open ("Master_Records"), adoCon, adOpenStatic, adLockOptimistic, adCmdTable

dbRecordCount = adoRec.RecordCount

<%
sqlString = "SELECT Current_day, ID , Pname, Surname, Blood_group , Married_Single, Ward , Bed, Admission_day ,Discharge_day , Illness ,Symptoms ,Comments ,Chronicle,Smoking
" &_
"FROM Master_Records " &_
"WHERE ID = 1 " &_
"AND ( Pname LIKE '%" & searchFor & "%' " &_
"OR Surname LIKE '%" & searchFor & "%') " &_
"ORDER BY Pname "

SET RS = Con.Execute( sqlString )
IF NOT RS.EOF AND searchFor <> "" THEN
%>

<%
WHILE NOT RS.EOF
%>
<%=RS( "Pname" )%>
<%=RS( "Surname" )%>


<%
RS.MoveNext
WEND
%>
<%
ELSE
%>
<table width="350" border=0
cellpadding=5 cellspacing=0>
<tr>
<td>
<font face="Arial" color="darkblue">
<b>No patient matched your search terms.</b>
</font>
</td>
</tr>
</table>
<%
END IF
%>

Nicodemas
04-09-2003, 02:05 AM
Maybe I'm missing where you called up this object, but here is something I spotted:

SET RS = Con.Execute( sqlString )

I see adoCon, but no objects on your page called just "Con". Does this help?

whiteadi
04-09-2003, 02:40 AM
If you put option explicit you must be very carefull to all variables to declare them and to use the correct name, like nicodemans noticed for connection con inexistent variable.