⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ado_recordset.asp

📁 方舟网免费空间申请程序(自助建站系统) v3.0 1 界面美观 2 后台管理功能强大:A 可以设置多种参数
💻 ASP
📖 第 1 页 / 共 2 页
字号:
'	Dim RStr 
 '   RStr = RS.GetString (2, , "</TD><TD>", "</TD></TR><TR><TD>") 
'	 Response.Write RStr
'---------//
		Response.write "</tr>"&_
				"<tr bgcolor='#ffffef'>"&_
				"<td colspan=6 height=22 bgcolor=#989898 ><span style='margin-left:200px;'>"&TABLE_NAME&"</font></td>"&_
				"</tr>"&_
				"</table>"
''IF myTABLE="" then 	myTABLE=iTABLE_NAME  '--------1 
''IF myTABLE="" then  '--------读出第一个表名
''	set rs=CONN.openSchema(4)
''	myTABLE=rs("TABLE_NAME") 
''	rs.close
''END IF 
		dim cols
		cols=false
		sql=trim(request("SQL"))
		if sql="" then
		cols=true
		sql="SELECT TOP 500 *  FROM "&chr(91)&myTABLE&chr(93)&""
		else
			if Ucase(left(trim(sql),6))<>"SELECT" then
				CONN.Execute sql
				if err.number<>0 then
					ErrOrINFO="<br>"+"<li>"&Err.Description&"。"
					err.clear
					ClosedataBase
					call errorX()
				else
					SUEssOrINFO="<br>"+"<li>查询:"&SQL&"完成。"
					call Suess()	
				end if
				CurrentPage=1
			else
			TABLE_NAME="<font color=#FFFFaa>当前查询结果:<b>"&myTABLE&"</b></font>"
			end if
		end if		
		rs.open sql,CONN,1,1
		if err.number<>0 then
			'sql="SELECT TOP 500 *  from "&chr(91)&iTABLE_NAME&chr(93)&""
			'rs.open sql,CONN,1,1
			ErrOrINFO="<br>"+"<li>"&Err.Description&"。<br><br><li>可能你改变了查询的数据库,请在上面点选新数据库的表"
			err.clear
			ClosedataBase
			call errorX()
		end if
	
	if not rs.eof then
		colCount=cint(RS.Fields.count)-1
		rs.PageSize = MaxPageSize	
		rs.AbsolutePage=CurrentPage
		Page_Count=0
		RowCount=rs.recordcount
		PageCountS=rs.PageCount
	 	call listTable()
		%><table width="100%"  border="0" cellpadding="4" cellspacing="0" background="pic/back.gif"'>
		<tr><td valign="bottom"><font color='#FFFFaa'><%
		call listPages()
		%></font></td ></tr></table><%
	else 
		call listNoTable()
	end if
	
'----------close datebase
		      rs.close
		set rs=nothing
		CloseDataBase
'------------------//
END IF '===============BASE_NAME

	Call EndHtmlTag()

REM ===========RecordeSet结果集=============

SUB listNoTABLE()
		Response.write "<table width='100%' align=center bgcolor=#989898 border=0 bordercolor=#666666 cellspacing=1 cellpadding=3>"
		Response.write "<tr bgcolor='#ffffef' align='center'>"
	for i=0 to RS.Fields.count-1
		Response.write "<td bgcolor='#ffeeff'>"&RS.Fields(i).name&"</td> "
	next
		Response.write "</tr>"&_
						"<tr  align='center'>"&_
						"<td colspan="&RS.Fields.count&" height=26 bgcolor='#ffffef'><font color=#000000>当前所选表无记录</font></td>"&_
						"</tr>"&_
						"</table>"

End SUB	

SUB listTable()
	Response.write "<table width='100%' align=center bgcolor='#989898' border=0 bordercolor=#666666 cellspacing=1 cellpadding=3>"
			Response.write "<tr bgcolor='#ffffef' align='center'>"
		for i=0 to colCount
			Response.write "<td bgcolor='#ffeeff'>"&RS.Fields(i).name&"</td> "
		next
			Response.write "</tr>"

			if cols=true then 		
			%><script>window.COLScount.innerHTML='<b><%=colCount+1%></b>';</script><% '把统计的表数写当上端				
			end if		
			
	'while Not rs.eof  and (Not Page_Count=rs.PageSize )
	while Not rs.eof  and (Not Page_Count=MaxPageSize )
	'rs.PageSize=20
	'for j=1 to rs.PageSize
		Response.write "<tr bgcolor='#ffffef'>"
		for i=0 to colCount
			ttt=""
			if len(rs(i))>16 then ttt="..."
			Response.write "<td>&nbsp;"&left(rs(i),16)&TTT&"</td> "
			'Response.write "<td bgcolor='#eeeeff'>"&RS.Fields(i).value&"</td> "
			'Response.write "<td bgcolor='#ffeeff'>"&RS.Fields(i).name&"</td> "
			'Response.write "<td bgcolor='#ffeeff'>"&RS.Fields.count&"</td> "
		next
			Response.write "</tr>"
		rs.movenext
	'next
	Page_Count=Page_Count+1
	wend
			Response.write "<tr bgcolor='#feffff' align='left'>"
			Response.write "<td colspan="&colCount+1&">"
			Response.write "&nbsp;&nbsp;Source:"&RS.Source&""		 		
			Response.write " //PageCount:"&rs.PageCount&""
			Response.write " //PageSize:"&rs.PageSize&""		
			'Response.write "rs.MaxRecords:"&rs.MaxRecords&"<br>"		 		
			'Response.write "rs.EditMode:"&rs.EditMode&"<br>" 		 		
			Response.write " //RecordCount:"&RS.RecordCount&"" 		 		
			Response.write " //fields.Count:"&RS.fields.Count&"" 		 		
			Response.write " //AbsolutePage:"&RS.AbsolutePage&"" 		 		
			'Response.write " CurrentPage:"&CurrentPage&"<br>" 		 		
			Response.write "</td> "
			Response.write "</tr>"
	Response.write "</table>"

	'----GetRows的方法--! 
	'dim arrRs 
	'arrRs=rs.GetRows
	'  Dim numRows 
	'  Dim numFlds 
	'  Dim row 
	'  Dim fld 
	'  numFlds = Ubound(arrRS, 1) 
	'  numRows = Ubound(arrRS, 2) 
	'Response.write "<table width='100%' align=center bgcolor=#989898 border=0 bordercolor=#666666 cellspacing=1 cellpadding=3>"
	'  For row= 0 to numRows 
	'  Response.Write("<TR>") 
	'  For fld = 0 to numFlds 
	'  Response.Write("<TD>" & arrRS(fld, row) & "</TD>") 
	'  Next 
	'  Response.Write("</TR>") 
	'  Next 
	'  Response.Write("</TABLE>") 
	'==
 End SUB

 SUB listPages()
	dim LastPage
		Response.write "&nbsp;&nbsp;<b>"&myTABLE&"</b>记录数:<b>"&RowCount&"</b>&nbsp;页次:<b>"&CurrentPage&"</b>/<b>"&PageCountS&"</b>&nbsp;"&_ 
					"每页:<b>"&MaxPageSize&"</b>条&nbsp;&nbsp;&nbsp;//&nbsp;页号:"
	if CurrentPage > 4 then
		Response.write "<a href='?BASEtype="&BASEtype&"&BASE_NAME="&BASE_NAME&"&DATA_Source="&DATA_Source&"&BaseOwner="&BaseOwner&"&table="&myTable&"&page=1'><font color=#00ffff>[1]</font></a> ..."
	end if
	if PageCountS>CurrentPage+3 then
		LastPage=CurrentPage+3
	else
		LastPage=PageCountS
	end if
	for i=CurrentPage-3 to LastPage
	if not i<1 then
		if i = clng(CurrentPage) then
        Response.write " <font color=#ffff00>["&i&"]</font>" 
		else
        Response.write " <a href='?BASEtype="&BASEtype&"&BASE_NAME="&BASE_NAME&"&DATA_Source="&DATA_Source&"&BaseOwner="&BaseOwner&"&table="&myTable&"&page="&i&"'><font color=#00ffff>["&i&"]</font></a>"
		end if
	end if
	next
		if CurrentPage+3 < PageCountS then 
		Response.write "... <a href='?BASEtype="&BASEtype&"&BASE_NAME="&BASE_NAME&"&DATA_Source="&DATA_Source&"&BaseOwner="&BaseOwner&"&table="&myTable&"&page="&PageCountS&"'><font color=#00ffff>["&PageCountS&"]</font></a>"
	end if
End SUB 

SUB errorX()
	'Rem 错误提示
	Response.write "<table cellpadding=0 cellspacing=0 border=0 height='100%' width='100%' bgcolor='#000000' align=center>"&_
			"<tr><td><table cellpadding=3 cellspacing=0 border=0 height='100%' width='100%'><tr align=center>"&_
			"<td width='100%' bgcolor=#f3f3f3 height=26><font color='#000000'><b>数据库查询器 错误信息</b></font></td>"&_
			"</tr><tr><td width=""100%"" bgcolor='#ffffff' align=center>"&_
			""&ErrOrINFO&"<br><br></font></td></tr><tr align=center><td width=""100%"" bgcolor=#f3f3f3>"
							Response.write"<span style='line-height:150%;letter-spacing: 5px;'>"&_
			"【<a href=javascript:history.go(-1)><font color='#000000'>返回到上一页</font></a>】<br>"&_
			"</span>"
	Response.write"</td></tr></table></td></tr></table></body></html>"
	Response.end()
	End SUB

	Rem'==== 正常提示
	SUB Suess()
	Response.write "<table cellpadding=0 cellspacing=0 border=0 width='100%' height='100%'  align=center>"&_
			"<tr><td><table cellpadding=3 cellspacing=1 border=0 width=""100%""><tr align=center>"&_
			"<td width='100%' bgcolor=#8CB59B height=26><b>查 询 执 行 成 功 </b></td>"&_
			"</tr><tr><td width=""100%"" bgcolor='#ffffff' align=center>"&_
			""&SUEssOrINFO&"<br><br></td></tr><tr align=center><td width=""100%"" bgcolor=#DBF2EB>"
	Response.write"<span style='line-height:150%;letter-spacing: 5px;'>"&_
			"【<a href=javascript:history.go(-1)>返回到上一页</a>】<br>"&_
			"</span>"
	Response.write"</td></tr></table></td></tr></table>"
	closedatabase
	Response.end
END SUB

'call CreateBASE()
'call CreatTable()

REM=====建立数据库文件.MDB====
SUB CreateBASE()
	dim CONNcreat,SQLcr,CrBaseName
	CrBaseName="data/AAABBB.MDB"
	set CONNcreat=SERVER.CreateObject("ADOX.CATALOG")
	SQLcr="Provider=Microsoft.Jet.OLEDB.4.0;Data Source="&server.mappath(CrBaseName)
	CONNcreat.Create SQLcr
End SUB


REM=========ACCESS==
SUB CreatTable()
	'----------需要刚建立的数据库文件才能进行建表!!
	dim rs
	dim CONNcreat,SQLcr,CrBaseName
	CrBaseName="data/AAABBB1.MDB"
	set CONNcreat=SERVER.CreateObject("ADOX.CATALOG")
	SQLcr="Provider=Microsoft.Jet.OLEDB.4.0;Data Source="&server.mappath(CrBaseName)
	CONNcreat.Create SQLcr
	set rs=SERVER.CreateObject("ADOX.TABLE")
	rs.Name="admins3"
	rs.columns.append "liuyan",203 
	rs.columns.append "dt",7
	CONNcreat.tables.append rs
	set rs=nothing
	if err.number<>0 then
			ErrOrINFO="<br>"+"<li>"&Err.Description&""+CONNErr
			err.clear
			call errorX()
	end if
	'Response.end
End SUB

SUB CreatTABLE2() 'for SQL
	Dim SQLstr
	SQLstr=""&_
	"CREATE TABLE [AAABBB] ("&_
		"[userName] [nvarchar] (50) COLLATE Chinese_PRC_CI_AS NULL ,"&_
		"[depositmoney] [int] NULL CONSTRAINT [a1] DEFAULT (0),"&_
		"[accrual] [int] NULL CONSTRAINT [a2] DEFAULT (0),"&_
		"[lendmoney] [int] NULL CONSTRAINT [a3] DEFAULT (0),"&_
		"[lendtime] [smalldatetime] NULL ,"&_
		"[deposittime] [smalldatetime] NULL ,"&_
		"[lockac] [int] NULL CONSTRAINT [a4] DEFAULT (0),"&_
		"[loaninterest] [int] NULL CONSTRAINT [a5] DEFAULT (0),"&_
		"[ac] [int] NULL CONSTRAINT [a6] DEFAULT (0)"&_
	") ON [PRIMARY]"
	CONN.Execute SQLstr

END SUB
REM=========改表名===== ACCESS
SUB ReNameTable()
	dim rs 
	set rs=server.createObject("ADOX.catalog")
	rs.Activeconnection=CONN
	rs.tables("TEST1reName").Name="test1"
	set rs=nothing
					if err.number<>0 then
						ErrOrINFO="<br>"+"<li>"&Err.Description&"。"
						err.clear
						ClosedataBase
						call errorX()
					end if	
END SUB

SUB EndHtmlTag()
%>
 </td>
    <td width="8"  bgcolor="#D4D0C8"><img src="" width=0 ></td>
  </tr>
</table>
	<table width="100%" height="0" border="0" align="center" cellpadding="6" cellspacing="0">
	<tr><td><font color='#888888'>
		
		</font></td></tr></table>

</body>
</html>		
<%
End SUB

'------ 过滤SQL非法字符
'Function checkStr(str)
'	if isnull(str) then
'		checkStr = ""
'		exit Function 
'	end if
'	checkStr=replace(str,"'","''")
'End Function

Function CloseDataBase()
		CONN.close
	set CONN=nothing
End Function
%>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -