I have a form with a drop down-menu to select the appropriate field from the database to search through and a text field to enter the search criteria. The drop-down menu also has a joint field to look up two memo fields in one go.
The problem is that I cannot get the SQL to search the database by the drop-down list joint field search. I've managed to get it working with single field searches but now I've hit a brick wall!
INFO... the drop-down list is called 'param'; the text box is called 'data; the twin field search is called 'joint'; the table is caleld 'pic_table'
<% Param = Request.QueryString("Param"
Data = Request.QueryString("Data"
data=replace(data,"'","''"
data=replace(data,"""",""""""
%>
<font face="Arial"><%If Param<>"" And Data <>"" then%>
</font>
<%
' set up database conection
' this connection does not require an ODBC reference
path = Trim(Server.MapPath("/fpdb"
)
conn_string = "DRIVER={Microsoft Access Driver (*.mdb)};DBQ=" + path + "\images.mdb"
Set con = Server.CreateObject("ADODB.Connection"
con.open conn_string
mode = "filtered"
mysql = "SELECT * FROM [pic_table] where"
If cstr(Param) <> "" And cstr(Data) <> "" Then
sql="[" & cstr(Param) & "] Like " & chr(39) &"%"& cstr(Data) &"%"& chr(39)& ";"
End If
Else
If cstr(Param) = "joint" And cstr(Data) <> "" Then
sql="[Pic_table].[details] or [keywords] like '" & cstr(data) & "'"
End If
rem single quote = 39, double quote = 34
Set rs = Server.CreateObject("ADODB.Recordset"
rs.Open sql, conn, 0,1
end if%>
Any comments would be appreciated...
Thanks in advance for your help,
Marcus
The problem is that I cannot get the SQL to search the database by the drop-down list joint field search. I've managed to get it working with single field searches but now I've hit a brick wall!
INFO... the drop-down list is called 'param'; the text box is called 'data; the twin field search is called 'joint'; the table is caleld 'pic_table'
<% Param = Request.QueryString("Param"
Data = Request.QueryString("Data"
data=replace(data,"'","''"
data=replace(data,"""",""""""
%>
<font face="Arial"><%If Param<>"" And Data <>"" then%>
</font>
<%
' set up database conection
' this connection does not require an ODBC reference
path = Trim(Server.MapPath("/fpdb"
conn_string = "DRIVER={Microsoft Access Driver (*.mdb)};DBQ=" + path + "\images.mdb"
Set con = Server.CreateObject("ADODB.Connection"
con.open conn_string
mode = "filtered"
mysql = "SELECT * FROM [pic_table] where"
If cstr(Param) <> "" And cstr(Data) <> "" Then
sql="[" & cstr(Param) & "] Like " & chr(39) &"%"& cstr(Data) &"%"& chr(39)& ";"
End If
Else
If cstr(Param) = "joint" And cstr(Data) <> "" Then
sql="[Pic_table].[details] or [keywords] like '" & cstr(data) & "'"
End If
rem single quote = 39, double quote = 34
Set rs = Server.CreateObject("ADODB.Recordset"
rs.Open sql, conn, 0,1
end if%>
Any comments would be appreciated...
Thanks in advance for your help,
Marcus