Pregunta: | 1398 - GUARDAR UNA IMAGEN EN UNA TABLA ACCES DESDE VB5 |
Autor: | Luis Godoy |
estoy Realizando una aplicación y tengo el problema de que no puedo guardar una imagen bmp o jpg en una tabla de access 97, para luego recuperarla ¿ como lo puedo hacer ? si es posible un ejemplo Gracias. |
Respuesta: | José Hernández Espinosa |
Este código hace exactamente lo que necesitas. Te sugiero que lo coloques en un módulo de código (*.bas) Saludos Pepe Private Const BlockSize = 32768 ´************************************************************** ´ FUNCTION: ReadBLOB() ´ ´ PURPOSE: ´ Reads a BLOB from a disk file and stores the contents in the ´ specified table and field. ´ ´ PREREQUISITES: ´ The specified table with the OLE object field to contain the ´ binary data must be opened in Visual Basic code (Access Basic ´ code in Microsoft Access 2.0 and earlier) and the correct record ´ navigated to prior to calling the ReadBLOB() function. ´ ´ ARGUMENTS: ´ Source - The path and filename of the binary information ´ to be read and stored. ´ T - The table object to store the data in. ´ Field - The OLE object field in table T to store the data in. ´ ´ RETURN: ´ The number of bytes read from the Source file. ´************************************************************** Function ReadBLOB(Source As String, T As Recordset, sField As String) Dim NumBlocks As Integer, SourceFile As Integer, i As Integer Dim FileLength As Long, LeftOver As Long Dim FileData As String Dim RetVal As Variant On Error GoTo Err_ReadBLOB ´ Open the source file. SourceFile = FreeFile Open Source For Binary Access Read As SourceFile ´ Get the length of the file. FileLength = LOF(SourceFile) If FileLength = 0 Then ReadBLOB = 0 Exit Function End If ´ Calculate the number of blocks |