<% class wawa_app_getrows public function wawa_get_list(strapp,strconn,strsql) ******************************** 功能:从application中提取数组,如果application中的数据为empty值的时候再调用wawa_get_rows()函数来给application赋值. ,你可以在修改数据库的时候把相应的application值清空成empty,这就浏览的时候就会自动更新application了 如果你更新了数据库(比如说添加,修改或者删除了数据)那么在修改数据库后把相应的application变量去掉, 用下面的一条语句来实现清空指定的application值,其中strapp参数是要去掉的application变量名 application.contents.remove(strapp) ******************************** dim wawa wawa = application(strapp) if isempty(wawa) then wawa = wawa_get_rows(strconn,strsql) application(strapp) = wawa end if wawa_get_list = wawa end function
public function wawa_get_rows(strconn,strsql) ******************************** 功能:从数据库里读取记录并用getrows方法 把记录保存成一个数组 ******************************** dim rs_wawa set rs_wawa = createobject(“adodb.recordset”) rs_wawa.open strsql,strconn,,1,1 wawa_get_rows = rs_wawa.getrows() rs_wawa.close set rs_wawa = nothing end function end class %> <!– 下面举个例子来说明上面的那个类怎么使用 –> <% dim strapp,strsql,strconn strapp=”employee” strsql=”select employeeid,titleofcourtesy,firstname,lastname,title,city from employees” strconn=”driver={sql server};server=192.168.0.110;database=northwind;uid=sa;pwd=sa;” set wawa_temp=new wawa_app_getrows arr_wawa=wawa_temp.wawa_get_list(strapp,strconn,strsql) %>
<% response.write(“<table width=100% border=0 cellspacing=1>”) dim i,j,rows,flds rows=ubound(arr_wawa,2) flds=ubound(arr_wawa,1) if rows>=0 then for i=0 to rows response.write(“<tr>”) for j=0 to flds response.write”<td>”&arr_wawa(j,i)&”</td>” next response.write(“</tr>”) next else response.write(“<tr><td>”&rows&”</td></tr>”) end if response.write(“</table>”) %> |