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

Rutina para acceder a base de datos y levantar imagenes

Estas en el tema de Rutina para acceder a base de datos y levantar imagenes en el foro de ASP Clásico en Foros del Web. hola a todos, me presento soy Roberto (Chile) y necesito que me ayuden en lo siguiente: actualmente tengo un requerimiento para realizar un sitio web ...
  #1 (permalink)  
Antiguo 13/05/2005, 17:33
 
Fecha de Ingreso: mayo-2005
Ubicación: Santiago
Mensajes: 10
Antigüedad: 19 años, 1 mes
Puntos: 0
Rutina para acceder a base de datos y levantar imagenes

hola a todos, me presento soy Roberto (Chile) y necesito que me ayuden en lo siguiente: actualmente tengo un requerimiento para realizar un sitio web con ASP clasico para una inmobiliaria (corretaje de propiedades) y para eso requiero que me ayuden en estas tres cosas:

1) Crear un mantenedor para la base de datos utlizada (Microsoft Access) que me permita Consultar, Borrar, Eliminar y Actualizar la información contenida en ella a través de internet.

2) Que dicho mantenedor permita levantar y grabar registros e imagenes (gif y jpg) asociadas a dichos registros (3 imagenes maximo por registro)

3) Alguna rutina que me permita buscar (a través de listas desplegables) por campos determinados y que como resultado me presente algun tipo de grilla que me permita seleccionar el o los registros a mostrar.

Agradeciendo de antemano vuestra amable ayuda, les saluda cordialmente

Roberto (Chile)
  #2 (permalink)  
Antiguo 13/05/2005, 17:43
Avatar de trasgukabi  
Fecha de Ingreso: septiembre-2004
Mensajes: 2.749
Antigüedad: 19 años, 9 meses
Puntos: 18
sabes algo al menos de ASP?
  #3 (permalink)  
Antiguo 13/05/2005, 18:11
 
Fecha de Ingreso: mayo-2005
Ubicación: Santiago
Mensajes: 10
Antigüedad: 19 años, 1 mes
Puntos: 0
estoy queriendo aprender, es por eso que pido ayuda para realizar estas rutinas, gracias
  #4 (permalink)  
Antiguo 13/05/2005, 18:14
Avatar de trasgukabi  
Fecha de Ingreso: septiembre-2004
Mensajes: 2.749
Antigüedad: 19 años, 9 meses
Puntos: 18
en mi firma tienes unos manuales perfectos para empezar.

Suerte!!
  #5 (permalink)  
Antiguo 13/05/2005, 18:29
 
Fecha de Ingreso: mayo-2005
Ubicación: Santiago
Mensajes: 10
Antigüedad: 19 años, 1 mes
Puntos: 0
trasbukabi:

El link a este libro no funciona:

BUEN LIBRO DE ASP. Contraseña-ASP31965.(PDF,Español,5 Mb)

Lo tienes en algun otro lado para descargar, gracias
  #6 (permalink)  
Antiguo 14/05/2005, 06:16
Avatar de trasgukabi  
Fecha de Ingreso: septiembre-2004
Mensajes: 2.749
Antigüedad: 19 años, 9 meses
Puntos: 18
Link arreglado
  #7 (permalink)  
Antiguo 15/05/2005, 02:46
 
Fecha de Ingreso: mayo-2005
Ubicación: Santiago
Mensajes: 10
Antigüedad: 19 años, 1 mes
Puntos: 0
Cita:
Iniciado por trasgukabi
Link arreglado
----------------------------------------------
Muchas Gracias trasgukabi... Un último favor, sería posible que me dieras alguna idea con respecto grabar registros de datos y dos(2) imagenes asociadas (gif y jpg) a cada registro a una base de datos access, ya tengo modificada y funcionando una que encontré, no recuerdo si en este foro o en otro sitio de ASP, pero no he podido o mejor dicho no he sabido modificarla para que asocie más de una imagen a la vez a cada registro (actualmente me funciona con una sola imagen asociada). La verdad es que te agradecería montones el que me ayudaras ya que tengo que entregar esa rutina el Lunes a primera hora y no he podido resolverlo... tengo claro que una de las reglas de ustedes es no entregar el codigo listo a los participantes de este foro, pero si no fuera tan importante, no te lo pediría...

De antemano muchas gracias por el apoyo....
  #8 (permalink)  
Antiguo 15/05/2005, 04:19
Avatar de trasgukabi  
Fecha de Ingreso: septiembre-2004
Mensajes: 2.749
Antigüedad: 19 años, 9 meses
Puntos: 18
pues nada, si tienes el código listo para la asociación de una imagen, tan sólo tienes que crear otro campo en la base de datos y asociar la segunda imagen (al menos eso ha sido lo que he entendido). Espero que los campos los hagas de tipo texto, que en el campo insertes sólo el nombre de la imagen y que, al desplegar esas imágenes, lo hagas así:

<img src="<%=rscordset("imagengif")%>">
<img src="<%=rscordset("imagenjpg")%>">

si no es ésto. explícalo otra vez, por favor.
  #9 (permalink)  
Antiguo 15/05/2005, 04:57
 
Fecha de Ingreso: mayo-2005
Ubicación: Santiago
Mensajes: 10
Antigüedad: 19 años, 1 mes
Puntos: 0
Cita:
Iniciado por trasgukabi
pues nada, si tienes el código listo para la asociación de una imagen, tan sólo tienes que crear otro campo en la base de datos y asociar la segunda imagen (al menos eso ha sido lo que he entendido). Espero que los campos los hagas de tipo texto, que en el campo insertes sólo el nombre de la imagen y que, al desplegar esas imágenes, lo hagas así:

<img src="<%=rscordset("imagengif")%>">
<img src="<%=rscordset("imagenjpg")%>">

si no es ésto. explícalo otra vez, por favor.
------------------------------------------------------------

trasgukabi, aqui te muestro el codigo fuente utilizado para levantar la imagen a la base de datos, estas son dos paginas una que realiza el insertar (insert.asp) y la otra que contiene las funciones para levantar la imagen (loader.asp):

inset.asp

<!--#include file="Loader.asp"-->
<%
Response.Buffer = True

' load object
Dim load
Set load = new Loader

' calling initialize method
load.initialize

' File binary data
Dim fileData
fileData = load.getFileData("file")
' File name
Dim fileName
fileName = LCase(load.getFileName("file"))
' File path
Dim filePath
filePath = load.getFilePath("file")
' File path complete
Dim filePathComplete
filePathComplete = load.getFilePathComplete("file")
' File size
Dim fileSize
fileSize = load.getFileSize("file")
' File size translated
Dim fileSizeTranslated
fileSizeTranslated = load.getFileSizeTranslated("file")
' Content Type
Dim contentType
contentType = load.getContentType("file")
' No. of Form elements
Dim countElements
countElements = load.Count

' Value of text input field "Propiedad"
Dim propiedad
propiedad = load.getValue("propiedad")
' Value of text input field "Transaccion"
Dim transaccion
transaccion = load.getValue("transaccion")
' Value of text input field "Region"
Dim region
region = load.getValue("region")
' Value of text input field "Comuna"
Dim comuna
comuna = load.getValue("comuna")
' Value of text input field "Barrio"
Dim barrio
barrio = load.getValue("barrio")
' Value of text input field "Precio"
Dim precio
precio = load.getValue("precio")
' Value of text input field "Terreno"
Dim terreno
terreno = load.getValue("terreno")
' Value of text input field "Otros"
Dim otros
otros = load.getValue("otros")
' Value of text input field "Detalles"
Dim detalles
detalles = load.getValue("detalles")


' destroying load object
Set load = Nothing
%>

<html>
<head>
<title>.:::::Arquiprop - Desarrollo Inmobiliario:::::.</title>
<style>
body, input, td { font-family:verdana,arial; font-size:10pt; }
</style>
</head>
<body bgproperties="fixed" background="imagenes/brillo.jpg">
<p align="center">
<b>Insertando Datos a la Base De Datos</b><br>
<a href="show.asp">Ver Datos Insertados</a>
</p>

<table width="700" border="1" align="center">
<tr>
<td>File Name</td><td><%= fileName %>&nbsp;</td>
</tr><tr>
<td>File Path</td><td><%= filePath %>&nbsp;</td>
</tr><tr>
<td>File Path Complete</td><td><%= filePathComplete %>&nbsp;</td>
</tr><tr>
<td>File Size</td><td><%= fileSize %>&nbsp;</td>
</tr><tr>
<td>File Size Translated</td><td><%= fileSizeTranslated %>&nbsp;</td>
</tr><tr>
<td>Content Type</td><td><%= contentType %>&nbsp;</td>
</tr><tr>
<td>No. of Form Elements</td><td><%= countElements %>&nbsp;</td>
</tr><tr>
<td>Tipo Propiedad</td><td><%= propiedad %>&nbsp;</td>
</tr><tr>
<td>Transaccion</td><td><%= transaccion %>&nbsp;</td>
</tr><tr>
<td>Region</td><td><%= region %>&nbsp;</td>
</tr><tr>
<td>Comuna</td><td><%= comuna %>&nbsp;</td>
</tr><tr>
<td>Barrio</td><td><%= barrio %>&nbsp;</td>
</tr><tr>
<td>Precio</td><td><%= precio %>&nbsp;</td>
</tr><tr>
<td>Terreno</td><td><%= terreno %>&nbsp;</td>
</tr><tr>
<td>Otros</td><td><%= otros %>&nbsp;</td>
</tr><tr>
<td>Detalles</td><td><%= detalles %>&nbsp;</td>
</tr>
</table><br><br>

<p style="padding-left:220;">
<%= fileName %> Datos recibidos ...<br>
<%
' Checking to make sure if file was uploaded
If fileSize > 0 Then

' Connection string
Dim connStr
connStr = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & Server.MapPath("FileDB.mdb")

' Recordset object
Dim rs
Set rs = Server.CreateObject("ADODB.Recordset")

rs.Open "Files", connStr, 2, 2

' Adding data
rs.AddNew
rs("File Name") = fileName
rs("File Size") = fileSize
rs("File Data").AppendChunk fileData
rs("Content Type") = contentType
rs("Propiedad") = propiedad
rs("Transaccion") = transaccion
rs("Region") = region
rs("Comuna") = comuna
rs("Barrio") = barrio
rs("Precio") = precio
rs("Terreno") = terreno
rs("Otros") = otros
rs("Detalles") = detalles
rs.Update

rs.Close
Set rs = Nothing

Response.Write "<font color=""green"">Archivo Grabado Satisfactoriamente...</font>"
Else
Response.Write "<font color=""brown"">No Fue Seleccionado Ningun Archivo Para Ser Grabado...</font>"
End If


If Err.number <> 0 Then
Response.Write "<br><font color=""red"">Ocurrio Un Error...</font>"
End If
%>
</p>

<br>
<table border="0" align="center">
<tr>
<form method="POST" enctype="multipart/form-data" action="Insert.asp">
<td>Tipo Propiedad :</td><td>
<input type="text" name="propiedad" size="40" value="TipoPropiedad"></td></tr>
<td>Transaccion :</td><td>
<input type="text" name="transaccion" size="40" value="Transaccion"></td></tr>
<td>Region :</td><td>
<input type="text" name="region" size="40" value="Region"></td></tr>
<td>Comuna :</td><td>
<input type="text" name="comuna" size="40" value="Comuna"></td></tr>
<td>Barrio :</td><td>
<input type="text" name="barrio" size="40" value="Barrio"></td></tr>
<td>Precio :</td><td>
<input type="text" name="precio" size="40" value="Precio"></td></tr>
<td>Terreno :</td><td>
<input type="text" name="terreno" size="40" value="Terreno"></td></tr>
<td>Otros :</td><td>
<input type="text" name="otros" size="40" value="Otros"></td></tr>
<td>Detalles :</td><td>
<input type="text" name="detalles" size="40" value="Detalles"></td></tr>

<td>File :</td><td>
<input type="file" name="file" size="40"></td></tr>
<td>&nbsp;</td><td>
<input type="submit" value="Submit"></td></tr>
</form>
</tr>
</table>

</body>
</html>

continua...
  #10 (permalink)  
Antiguo 15/05/2005, 05:01
Avatar de trasgukabi  
Fecha de Ingreso: septiembre-2004
Mensajes: 2.749
Antigüedad: 19 años, 9 meses
Puntos: 18
jejeje...no pretenderás que me lea todo eso con el pedo que llevo.......Te juro por todos mis muertos que para asociar dos imágenes a una registro no hace falta ingeniería genética (que parece que es lo que tú estás haciendo. la virgen que complicaciones)

en mi post anterior tienes las pautas a seguir. ¡Vamos a echarle un poquito de imaginación!
  #11 (permalink)  
Antiguo 15/05/2005, 05:02
 
Fecha de Ingreso: mayo-2005
Ubicación: Santiago
Mensajes: 10
Antigüedad: 19 años, 1 mes
Puntos: 0
loader.asp

<%
Class Loader
Private dict

Private Sub Class_Initialize
Set dict = Server.CreateObject("Scripting.Dictionary")
End Sub

Private Sub Class_Terminate
If IsObject(intDict) Then
intDict.RemoveAll
Set intDict = Nothing
End If
If IsObject(dict) Then
dict.RemoveAll
Set dict = Nothing
End If
End Sub

Public Property Get Count
Count = dict.Count
End Property

Public Sub Initialize
If Request.TotalBytes > 0 Then
Dim binData
binData = Request.BinaryRead(Request.TotalBytes)
getData binData
End If
End Sub

Public Function getFileData(name)
If dict.Exists(name) Then
getFileData = dict(name).Item("Value")
Else
getFileData = ""
End If
End Function

Public Function getValue(name)
Dim gv
If dict.Exists(name) Then
gv = CStr(dict(name).Item("Value"))

gv = Left(gv,Len(gv)-2)
getValue = gv
Else
getValue = ""
End If
End Function

Public Function saveToFile(name, path)
If dict.Exists(name) Then
Dim temp
temp = dict(name).Item("Value")
Dim fso
Set fso = Server.CreateObject("Scripting.FileSystemObject")
Dim file
Set file = fso.CreateTextFile(path)
For tPoint = 1 to LenB(temp)
file.Write Chr(AscB(MidB(temp,tPoint,1)))
Next
file.Close
saveToFile = True
Else
saveToFile = False
End If
End Function

Public Function getFileName(name)
If dict.Exists(name) Then
Dim temp, tempPos
temp = dict(name).Item("FileName")
tempPos = 1 + InStrRev(temp, "\")
getFileName = Mid(temp, tempPos)
Else
getFileName = ""
End If
End Function

Public Function getFilePath(name)
If dict.Exists(name) Then
Dim temp, tempPos
temp = dict(name).Item("FileName")
tempPos = InStrRev(temp, "\")
getFilePath = Mid(temp, 1, tempPos)
Else
getFilePath = ""
End If
End Function

Public Function getFilePathComplete(name)
If dict.Exists(name) Then
getFilePathComplete = dict(name).Item("FileName")
Else
getFilePathComplete = ""
End If
End Function

Public Function getFileSize(name)
If dict.Exists(name) Then
getFileSize = LenB(dict(name).Item("Value"))
Else
getFileSize = 0
End If
End Function

Public Function getFileSizeTranslated(name)
If dict.Exists(name) Then
temp = 1 + LenB(dict(name).Item("Value"))
If Len(temp) <= 3 Then
getFileSizeTranslated = temp & " bytes"
ElseIf Len(temp) > 6 Then
temp = FormatNumber(((temp / 1024) / 1024), 2)
getFileSizeTranslated = temp & " megabytes"
Else
temp = FormatNumber((temp / 1024), 2)
getFileSizeTranslated = temp & " kilobytes"
End If
Else
getFileSizeTranslated = ""
End If
End Function

Public Function getContentType(name)
If dict.Exists(name) Then
getContentType = dict(name).Item("ContentType")
Else
getContentType = ""
End If
End Function

Private Sub getData(rawData)
Dim separator
separator = MidB(rawData, 1, InstrB(1, rawData, ChrB(13)) - 1)

Dim lenSeparator
lenSeparator = LenB(separator)

Dim currentPos
currentPos = 1
Dim inStrByte
inStrByte = 1
Dim value, mValue
Dim tempValue
tempValue = ""

While inStrByte > 0
inStrByte = InStrB(currentPos, rawData, separator)
mValue = inStrByte - currentPos

If mValue > 1 Then
value = MidB(rawData, currentPos, mValue)

Dim begPos, endPos, midValue, nValue
Dim intDict
Set intDict = Server.CreateObject("Scripting.Dictionary")

begPos = 1 + InStrB(1, value, ChrB(34))
endPos = InStrB(begPos + 1, value, ChrB(34))
nValue = endPos

Dim nameN
nameN = MidB(value, begPos, endPos - begPos)

Dim nameValue, isValid
isValid = True

If InStrB(1, value, stringToByte("Content-Type")) > 1 Then

begPos = 1 + InStrB(endPos + 1, value, ChrB(34))
endPos = InStrB(begPos + 1, value, ChrB(34))

If endPos = 0 Then
endPos = begPos + 1
isValid = False
End If

midValue = MidB(value, begPos, endPos - begPos)
intDict.Add "FileName", trim(byteToString(midValue))

begPos = 14 + InStrB(endPos + 1, value, stringToByte("Content-Type:"))
endPos = InStrB(begPos, value, ChrB(13))

midValue = MidB(value, begPos, endPos - begPos)
intDict.Add "ContentType", trim(byteToString(midValue))

begPos = endPos + 4
endPos = LenB(value)

nameValue = MidB(value, begPos, ((endPos - begPos) - 1))
Else
nameValue = trim(byteToString(MidB(value, nValue + 5)))
End If

If isValid = True Then

intDict.Add "Value", nameValue
intDict.Add "Name", nameN

dict.Add byteToString(nameN), intDict
End If
End If

currentPos = lenSeparator + inStrByte
Wend
End Sub

End Class

Private Function stringToByte(toConv)
Dim tempChar
For i = 1 to Len(toConv)
tempChar = Mid(toConv, i, 1)
stringToByte = stringToByte & chrB(AscB(tempChar))
Next
End Function

Private Function byteToString(toConv)
For i = 1 to LenB(toConv)
byteToString = byteToString & chr(AscB(MidB(toConv,i,1)))
Next
End Function
%>

*******************

si te fijas los campos

rs("File Name") = fileName
rs("File Size") = fileSize
rs("File Data").AppendChunk fileData
rs("Content Type") = contentType

guardan la imagen asociada al registro en la base de datos y lo que necesito es que me guarde dos(2) imagenes asociadas y no una(1) como lo esta haciendo ahora.....

Gracias por tu ayuda e interes...

Roberto
  #12 (permalink)  
Antiguo 15/05/2005, 05:05
Avatar de trasgukabi  
Fecha de Ingreso: septiembre-2004
Mensajes: 2.749
Antigüedad: 19 años, 9 meses
Puntos: 18
primera cosa mala:
poner espacios en los nombres de campo.
y la refinitiva:
qué te cuesta duplicar los campos (filename y filename2, filesize y filesize2....) y ejecutar esa maraña de programa dos veces?
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 21:00.