gracias ...
Para insertar un fichero en un campo image de SQL Server con Stream:
------------------------------------------------------------------------
Dim sSQL As String
Dim oRs As New Recordset
Dim oST As New Stream
With oRs
sSQL = "SELECT * FROM TuTabla WHERE Campo = Valor"
'Si el fichero es grande aumenta el timeout por si acaso
oCon.CommandTimeout = 200
'Abre el RS
.Open sSQL, oCon, adOpenDynamic, adLockOptimistic
oCon.CommandTimeout = 30
'Crea un Stream binario, lo abre e inserta el fichero
oST.Type = adTypeBinary
oST.Open
oST.LoadFromFile "PathDeTuFichero"
'Coloca el valor del stream en el campo, graba y voilá
.Fields("TuCampo") = oST.Read
.Update
oST.Close
.Close
End With
****************************************************************
Para leer las imagenes de la base de datos
****************************************************************
Private Sub CargarImagen()
(...)
Dim oRs As New Recordset
Dim oST As Stream
Const sFile1 = "\Temp1.jpg"
Screen.MousePointer = vbArrowHourglass
oRs.Open "SELECT * FROM DAT_LogosEmpresas WHERE IdRowEmpresa=" &
pIdRowEmp, oCon
If Not oRs.EOF Then
If Not IsNull(oRs("iEnc")) Then
Set oST = New Stream
oST.Type = adTypeBinary
oST.Open
oST.Write oRs.Fields("iEnc").Value
oST.SaveToFile App.Path & sFile1, adSaveCreateOverWrite
Me.iEnc.Image = LoadPicture(App.Path & sFile1)
Kill (App.Path & sFile1)
oST.Close
Set oST = Nothing
End If
End If
oRs.Close
Screen.MousePointer = vbDefault
Exit Sub
err2:
Screen.MousePointer = vbDefault
MsgBox Err.Description, vbCritical
End Sub
Un Saludo!
--
Lluís Franco i Montanyés
[MS-MVP-MCP Visual Basic]
FIMARGE, S.A.
Principat d'Andorra
lfranco@ODIO_EL_SPAMfimarge.ad
Tel.: +376 805 100
Fax: +376 824 500
Mi Perfil MVP en: http://tinyurl.com/4nbnb
This posting is provided "AS IS" with no warranties, and confers no rights.
Este mensaje se proporciona "COMO ESTA" sin garantias y no otorga ningun
derecho
--
(Guía de netiquette del foro)
http://www.uyssoft.com/Netiquette/