<% 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>") %> |