onlytiancai [原作]
1
2Class wawa_app_getrows
3public Function wawa_Get_List(strapp,strconn,strsql)
4'********************************
5'功能:从Application中提取数组,如果application中的数据为empty值的时候再调用wawa_Get_Rows()函数来给application赋值.
6' ,你可以在修改数据库的时候把相应的application值清空成empty,这就浏览的时候就会自动更新application了
7' 如果你更新了数据库(比如说添加,修改或者删除了数据)那么在修改数据库后把相应的application变量去掉,
8' 用下面的一条语句来实现清空指定的application值,其中strapp参数是要去掉的application变量名
9' application.Contents.Remove(strapp)
10' www.knowsky.com
11'********************************
12Dim wawa
13wawa = Application(strapp)
14If isempty(wawa) Then
15wawa = wawa_Get_Rows(strconn,strsql)
16Application(strapp) = wawa
17End If
18wawa_Get_List = wawa
19End Function
20
21public Function wawa_Get_Rows(strconn,strsql)
22'********************************
23'功能:从数据库里读取记录并用getrows方法
24' 把记录保存成一个数组
25'
26'********************************
27Dim rs_wawa
28Set rs_wawa = CreateObject("ADODB.Recordset")
29rs_wawa.Open strsql,strconn,,1,1
30wawa_Get_Rows = rs_wawa.GetRows()
31rs_wawa.Close
32Set rs_wawa = Nothing
33End Function
34End Class
1
2dim strapp,strsql,strconn
3strapp="xinwendongtai"
4
5strsql="select top 5 id,title from wen where lei=161 order by id desc"
6strconn="Driver={sql server};server=192.168.0.110;database=new;uid=sa;pwd=sa;"
7set wawa_temp=new wawa_app_getrows
8arr_xinwendongtai=wawa_temp.wawa_Get_LIst(strapp,strconn,strsql)
1<table border="0" cellspacing="1" width="100%">
If ubound(arr_xinwendongtai)<>0 Then
for i=0 to ubound(arr_xinwendongtai,2)-1
1<tr>
2<td><a href="view.asp?id=```
3= arr_xinwendongtai(0,i)
4```">```
5= arr_xinwendongtai(1,i)
6```</a></td>
7</tr>
next
Else
1<tr>
2<td>还没有新闻呢</td>
3</tr>
End If
1</table>