<%
On Error Resume Next
Dim Conn,ConnStr
ConnStr = "Provider = Microsoft.Jet.OLEDB.4.0;Data Source = " & Server.MapPath("a.mdb")
Set Conn = Server.CreateObject("ADODB.Connection")
Conn.connectionstring = ConnStr
Conn.open
If Err Then
Err.Clear
Conn.close()
Set Conn = Nothing
Response.Clear()
Response.Write "数据库连接出错!"
Response.End
End If
Dim myComm,rs,myRs
on error resume next
Connectdb()
Set myComm = Server.CreateObject("ADODB.COMMAND")
With myComm
.ActiveConnection = Conn
.CommandText = "select * from [db]"
.CommandType = &H0001
.Prepared = true
End With
set rs = myComm.Execute()
Dim Vtemp:Vtemp = rs.Getrows '这里将记录集赋值在一个二维数组中,这个方法性能是一个抛物线。
rs.close
set rs = nothing
Conn.close
set Conn = nothing
'==================以上是数据库查询,以下是核心程序==================
Dim i,V,Vt,Str
for i=0 to UBound(Vtemp,2)
Vt = Vt&","&Vtemp(1,i)
next
Vt = mid(Vt,2)
V = split(Vt,",")
str = "共有"&UBound(V)+1&"个元素,其中:"
for i=0 to UBound(V)
if not Instr(str,V(i))>0 then
len(Vt)-len(replace(Vt,V(i),""))
str = str&V(i)&len(Vt)-len(replace(Vt,V(i),""))&"个,"
end if
next
Response.Write(str&"<br />"&Vt)
%>