<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<!--#include file="Connections/gz.asp" -->
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>无标题文档</title>
</head>
<body>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td>66666</td>
</tr>
<tr>
<td><form name="form1" method="post" action="test.asp">
姓名:
<input name="ygxm" type="text" id="ygxm">
年月:
<input name="adddate" type="text" id="adddate">
<input type="submit" name="Submit" value="提交">
</form></td>
</tr>
<tr>
<td> </td>
</tr>
</table>
<%
dim ygxm,adddate,rs
ygxm=request.form("ygxm")
adddate=request.form("adddate")
if ygxm<>"" and adddate="" then
sql="select * from dbo.hz where ygxm = '"&ygxm&"'" '这个比较根据你的实际情况写比较符号
end if
if ygxm="" and adddate<>"" then
sql="select * from dbo.hz where adddate like '%"+ adddate + "%'" '这个比较根据你的实际情况写比较符号
end if
if ygxm<>"" and adddate<>"" then
sql="select * from dbo.hz where ygxm = '"&ygxm&"' and adddate like '%"+ adddate + "%'" '这个比较根据你的实际情况写比较符号
end if
set rs=Server.CreateObject("ADODB.RecordSet")
rs.ActiveConnection = MM_gz_STRING
rs.Source = sql
rs.CursorType = 1
rs.CursorLocation = 3
rs.LockType = 3
rs.Open()
rs.PageSize = 20
'这里设定每页显示的记录数
pre = true
last = true
page = trim(Request.QueryString("page"))
if len(page) = 0 then
intpage = 1
pre = false
else
if cint(page) =< 1 then
intpage = 1
pre = false
else
if cint(page) >= rs.PageCount then
intpage = rs.PageCount
last = false
else
intpage = cint(page)
end if
end if
end if
if not rs.eof then
rs.AbsolutePage = intpage
end if
%>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<% If Not rs.EOF Or Not rs.BOF Then %> <tr><%
for i=1 to rs.PageSize
if rs.EOF or rs.BOF then exit for
%><td><%=rs.Fields.Item("ygxm")%></td>
</tr><%
rs.MoveNext()
next
%> <% End If ' end Not rs1.EOF Or NOT rs1.BOF %>
<tr>
<td> </td>
</tr>
<tr>
<td> </td>
</tr>
</table>
</body>
</html>
全文如下,我想通过表单提交参数查询,可是出现如下错误
错误类型:
Microsoft OLE DB Provider for ODBC Drivers (0x80040E0C)
没有为命令对象设置命令。
/shoes/test.asp, 第 49 行
<!--#include file="Connections/gz.asp" -->
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" <html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>无标题文档</title>
</head>
<body>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td>66666</td>
</tr>
<tr>
<td><form name="form1" method="post" action="test.asp">
姓名:
<input name="ygxm" type="text" id="ygxm">
年月:
<input name="adddate" type="text" id="adddate">
<input type="submit" name="Submit" value="提交">
</form></td>
</tr>
<tr>
<td> </td>
</tr>
</table>
<%
dim ygxm,adddate,rs
ygxm=request.form("ygxm")
adddate=request.form("adddate")
if ygxm<>"" and adddate="" then
sql="select * from dbo.hz where ygxm = '"&ygxm&"'" '这个比较根据你的实际情况写比较符号
end if
if ygxm="" and adddate<>"" then
sql="select * from dbo.hz where adddate like '%"+ adddate + "%'" '这个比较根据你的实际情况写比较符号
end if
if ygxm<>"" and adddate<>"" then
sql="select * from dbo.hz where ygxm = '"&ygxm&"' and adddate like '%"+ adddate + "%'" '这个比较根据你的实际情况写比较符号
end if
set rs=Server.CreateObject("ADODB.RecordSet")
rs.ActiveConnection = MM_gz_STRING
rs.Source = sql
rs.CursorType = 1
rs.CursorLocation = 3
rs.LockType = 3
rs.Open()
rs.PageSize = 20
'这里设定每页显示的记录数
pre = true
last = true
page = trim(Request.QueryString("page"))
if len(page) = 0 then
intpage = 1
pre = false
else
if cint(page) =< 1 then
intpage = 1
pre = false
else
if cint(page) >= rs.PageCount then
intpage = rs.PageCount
last = false
else
intpage = cint(page)
end if
end if
end if
if not rs.eof then
rs.AbsolutePage = intpage
end if
%>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<% If Not rs.EOF Or Not rs.BOF Then %> <tr><%
for i=1 to rs.PageSize
if rs.EOF or rs.BOF then exit for
%><td><%=rs.Fields.Item("ygxm")%></td>
</tr><%
rs.MoveNext()
next
%> <% End If ' end Not rs1.EOF Or NOT rs1.BOF %>
<tr>
<td> </td>
</tr>
<tr>
<td> </td>
全文如下,我想通过表单提交参数查询,可是出现如下错误错误类型:
Microsoft OLE DB Provider for ODBC Drivers (0x80040E0C)没有为命令对象设置命令。shoes/test.asp, 第 49 行
第49行为“rs.Open()”