(附上我上次提出的问题:请问,由多个下拉表单构成的查询数据库的系统,怎样才能实现只选其中一至二个下拉表单,其余忽略不选,也能查到正确的数据?现在我只能每个表单都选,才能查到数据......)
我已经修改了代码,现在全部忽略查询和根据性别一项查询已经可以得到正确的结果,但是根据姓和出生年份查询,以及这三项组合查询还是查不出结果,请高手帮忙看看那里有问题?
<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<!--#include file="../../Connections/data1.asp" -->
<%
Dim Recordset1__MMColParam
Recordset1__MMColParam = ""
If (Request.Form("select1") <> "") Then
Recordset1__MMColParam = Request.Form("select1")
End If
%>
<%
Dim Recordset1__MMColParam1
Recordset1__MMColParam1 = ""
If (Request.Form("select2") <> "") Then
Recordset1__MMColParam1 = Request.Form("select2")
End If
%>
<%
Dim Recordset1__MMColParam2
Recordset1__MMColParam2 = ""
If (Request.Form("select3") <> "") Then
Recordset1__MMColParam2 = Request.Form("select3")
End If
%>
<%
set Recordset1 = Server.CreateObject("ADODB.Recordset")
Recordset1.ActiveConnection = MM_data1_STRING
Recordset1.Source ="SELECT * FROM data_table where 1"
if (Recordset1__MMColParam <> "") Then
Recordset1.Source = Recordset1.Source & " and yourname like '" + Replace(Recordset1__MMColParam, "'", "''") +"'"
end if
if (Recordset1__MMColParam1 <> "") Then
Recordset1.Source = Recordset1.Source & " and sex = '" + Replace(Recordset1__MMColParam1, "'", "''") +"'"
end if
if (Recordset1__MMColParam2 <> "") Then
Recordset1.Source = Recordset1.Source & " and brith like '" + Replace(Recordset1__MMColParam2, "'", "''") +"'"
end if
Recordset1.CursorType = 0
Recordset1.CursorLocation = 2
Recordset1.LockType = 3
Recordset1.Open()
Recordset1_numRows = 0
%>
<%
Dim Repeat1__numRows
Repeat1__numRows = 20
Dim Repeat1__index
Repeat1__index = 0
Recordset1_numRows = Recordset1_numRows + Repeat1__numRows
%>
