Foros del Web » Programando para Internet » ASP Clásico »

cargar RS creado con FSO en Access

Estas en el tema de cargar RS creado con FSO en Access en el foro de ASP Clásico en Foros del Web. Hola amigos. A ver la solidaridad como anda..! Bien: tengo un recorset que se crea con fso. Me lista todos los archivos de una carpeta, ...
  #1 (permalink)  
Antiguo 14/09/2005, 01:48
 
Fecha de Ingreso: febrero-2005
Mensajes: 17
Antigüedad: 20 años, 2 meses
Puntos: 0
cargar RS creado con FSO en Access

Hola amigos. A ver la solidaridad como anda..!
Bien: tengo un recorset que se crea con fso. Me lista todos los archivos de una carpeta, y yo Necesito insertar esos registros en Access
Basta de cháchara! acá está el código, valientes!

<%
'**********
'kc_fsoFiles
'Purpose:
' 1. To create a recordset using the FSO object and ADODB
' 2. Allows you to exclude files from the recordset if needed
'Use:
' 1. Call the function when you're ready to open the recordset
' and output it onto the page.
' example:
'Dim rsFSO, strPath
'strPath = Server.MapPath("\ordenes\FSO\Stuff\")
' Set rsFSO = kc_fsoFiles(strPath, "_")
' The "_" will exclude all files beginning with
' an underscore
'**********
Function kc_fsoFiles(theFolder, Exclude)
Dim rsFSO, objFSO, objFolder, File
Const adInteger = 3
Const adDate = 7
Const adVarChar = 200

'create an ADODB.Recordset and call it rsFSO
Set rsFSO = Server.CreateObject("ADODB.Recordset")

'Open the FSO object
Set objFSO = Server.CreateObject("Scripting.FileSystemObject")

'go get the folder to output it's contents
Set objFolder = objFSO.GetFolder(theFolder)

'Now get rid of the objFSO since we're done with it.
Set objFSO = Nothing

'create the various rows of the recordset
With rsFSO.Fields
.Append "Name", adVarChar, 200
.Append "Type", adVarChar, 200
.Append "DateCreated", adDate
.Append "DateLastAccessed", adDate
.Append "DateLastModified", adDate
.Append "Size", adInteger
.Append "TotalFileCount", adInteger
End With
rsFSO.Open()

'Now let's find all the files in the folder
For Each File In objFolder.Files

'hide any file that begins with the character to exclude
If (Left(File.Name, 1)) <> Exclude Then
rsFSO.AddNew
rsFSO("Name") = File.Name
rsFSO("Type") = File.Type
rsFSO("DateCreated") = File.DateCreated
rsFSO("DateLastAccessed") = File.DateLastAccessed
rsFSO("DateLastModified") = File.DateLastModified
rsFSO("Size") = File.Size
rsFSO.Update
End If

Next

'And finally, let's declare how we want the files
'sorted on the page. In this example, we are sorting
'by File Type in descending order,
'then by Name in an ascending order.
rsFSO.Sort = "name asc"

'Now get out of the objFolder since we're done with it.
Set objFolder = Nothing

'now make sure we are at the beginning of the recordset
'not necessarily needed, but let's do it just to be sure.
rsFSO.MoveFirst()
Set kc_fsoFiles = rsFSO

End Function

'Now let's call the function and open the recordset on the page
'the folder we will be displaying
Dim strFolder : strFolder = (Server.MapPath ("\ordenes") & "\"&fcount&"")

'the actual recordset we will be creating with the kc_fsoFiles function
Dim rsFSO 'now let's call the function and open the recordset

'we will exclude all files beginning with a "_"
Set rsFSO = kc_fsoFiles(strFolder, "_")

'now we'll create a loop and start displaying the folder
'contents with our recordset. Of course, this is just a
'simple example and not very well formatted, i.e., not in
'a table, but it gets the point across on how you can
'ouput the recordset on the page.
While Not rsFSO.EOF
%>
<form name="form1" method="post" action="">
<table width="100%" style="
BORDER-bottom: rgb(102,102,102) 1px solid width="100%">
<!--DWLayoutTable-->
<tr>
<td class=le_ch width="81" height="124"> <div align="center">
<input class=in_contac type="checkbox" name="<%= rsFSO("Name").Value %>" value="<%= rsFSO("Name").Value %>">
<br>
<%= rsFSO("Name").Value %>
<input name="nom" type="hidden" id="ver" value="<%= rsFSO("name").Value %>
<%= rsFSO("TotalFileCount").Value %> </p></td>
<td> <div align="center">
</div></td>
<td width="174" valign="middle" class=le_az> <p align="center"><img src="http://www.zoomlab.com.ar/ordenes/<%=fcount%>/<%= rsFSO("Name").Value %>" width="120" border="1" bordercolor=cccccc id=ipreview></p></td>
<td width="108"> <p align="center">
<select class=in_contac name="<%= rsFSO("Name").Value %>">
<option value="1" selected>1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>

</select>
<br>
</td>
<td width="93"><!--DWLayoutEmptyCell-->&nbsp;</td>
</tr>
</table>
</form>
<p>
<%
'and let's move to the next record
rsFso.MoveNext()
Wend

'finally, close out the recordset
rsFSO.close()
Set rsFSO = Nothing
%>

LA IDEA ES VOLCAR AL MENOS EL NOMBRE DE LA FOTO EN UNA DB

MUCHAS GRACIAS POR SU VALIOSA AYUDA
  #2 (permalink)  
Antiguo 14/09/2005, 02:06
 
Fecha de Ingreso: marzo-2005
Mensajes: 276
Antigüedad: 20 años, 2 meses
Puntos: 0
Bua!! todo ese código no me apetece leer y empezar a pensar q hace, explica bien q es lo q hace tu código y q es lo quieres hacer por favor, tal vez así pueda ayudarte...
  #3 (permalink)  
Antiguo 14/09/2005, 10:36
Avatar de AlZuwaga
Colaborador
 
Fecha de Ingreso: febrero-2001
Ubicación: 34.517 S, 58.500 O
Mensajes: 14.550
Antigüedad: 24 años, 2 meses
Puntos: 535
Y necesitás hacer el si o si el recordset?
Pregunto porque una vez hice lo mismo, levantar los datos de los archivos de una carpeta mediante FSO y mandarlos a una recordset para poder ordenarlos más facilmente, pero sin necesidad de guardarlos en una tabla.

Como sea, necesitás una conexión a la base de datos y luego hacer el insert dentro del for...next:

Código:
...
'declarás el objeto conexion
...
 'Now let's find all the files in the folder
For Each File In objFolder.Files

'hide any file that begins with the character to exclude
If (Left(File.Name, 1)) <> Exclude Then
rsFSO.AddNew
rsFSO("Name") = File.Name
rsFSO("Type") = File.Type
rsFSO("DateCreated") = File.DateCreated
rsFSO("DateLastAccessed") = File.DateLastAccessed
rsFSO("DateLastModified") = File.DateLastModified
rsFSO("Size") = File.Size
rsFSO.Update

SQL = "INSERT INTO tabla (nombre, tipo, creado, ult_acceso, ult_modific, tamaNIo) VALUES ('" & File.Name & "', '" & File.Type & "', '" & File.DateCreated & "', '" & File.DateLastAccessed & "', '" & File.DateLastModified & "', '" & File.Size & "')"

ObjetoConexion.Execute(SQL)


End If

Next
...
__________________
...___...
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 04:47.