Page rs.asp <OBJECT RUNAT= "SERVER" SCOPE="page" ID="fso" PROGID="Scripting.fileSystemObject"></OBJECT> <% function getAuthors( startPos , nbRows , bForce ) dim sql , cn , rsData set rsData = Server.CreateObject("ADODB.recordset") 'si on ne force pas l'interrogation au serveur, et que le fichier existe on l'ouvre à partir du disque if ( not bForce and fso.FileExists( Server.MapPath(Session.SessionID + "rs"))) then rsData.Open Server.MapPath(Session.SessionID + "rs") else 'sinon, on execute la requete set cn = Server.CreateObject("ADODB.connection") sql = "select * from authors" rsData.CursorLocation=adUseClient rsData.CacheSize=20 cn.ConnectionString=Application("connectionString") cn.Open rsData.Open sql,cn set rsData.ActiveConnection=nothing cn.Close set cn = nothing 'on supprime un éventuelle version sur disque if ( fso.FileExists( Server.MapPath(Session.SessionID + "rs"))) then call fso.DeleteFile( Server.MapPath(Session.SessionID + "rs"),true) end if 'on ectit le recordset sur disque call rsData.Save (Server.MapPath(Session.SessionID + "rs"),adPersistADTG ) end if 'on se positione à la position de départ rsData.Move(startPos) ' on copie les données dans un tableau 'l'utilisation d'un tableau est plus rapide que la navigation dans un recordset 'on retourne le tableau getAuthors = rsData.GetRows( nbRows ) exit function end function dim arValues arValues = getAuthors(0, 100, false) for i = 0 to ubound( arValues , 2 ) 'lignes Response.Write " ********** #" & i & " " for j = 0 to ubound( arValues , 1 ) 'colonnes Response.Write arValues( j , i ) & " " next next %> global.asa <!--metadata name ="Microsoft ActiveX Data Objects 2.6 Library" type="TypeLib" uuid="{00000206-0000-0010-8000-00AA006D2EA4}"--> <SCRIPT LANGUAGE="vbscript" RUNAT=Server> sub Application_OnStart Application("connectionString") = "dsn=tom;uid=sa;Password=******;" end sub sub Session_OnStart end sub 'on supprime les données cachées 'dans le Session_OnEnd, aucun des object intrinsect ne fonctionne 'on a juste accé au Session.SessionID il faut donc écrire le chemin en dur sub Session_OnEnd dim fso set fso = Server.CreateObject("Scripting.fileSystemObject") if fso.FileExists( "C:\Inetpub\wwwroot\forum\recordset" & Session.SessionID & "rs" ) then call fso.DeleteFile( "C:\Inetpub\wwwroot\forum\recordset" & Session.SessionID & "rs", true) end if set fso=nothing end sub </SCRIPT>
rs.sort="nom desc, prenom"