Cargar imagenes en una Base de Datos
Nesecito que me digan como hago para leer un archivo JPG, BMP o Gif para cargar su contenido y insertarlo en una Base de Datos basicamente Oracle o SQLServer2000. Estoy trabajando en delphi 6 y nesecito saber esto con urgencia, si pueden ayudarmen con todos los detalles se los agradecere mucho.
Pues ya te publiqué un código que encontré en CodeCentral... ojalá y te sirva... la verdad es que no soy un experto en Delphi.. y lo poco que sé lo he hecho con Kylix
var
myParams : TParams;
cSQL : string;
FileStream : TFileStream;
begin
// this just sets up the testing environment
// SQLConnection1 is an open DBExpress TSQLConnection
SQLConnection1.ExecuteDirect('DELETE FROM BLOBS3');
SQLConnection1.ExecuteDirect('INSERT INTO BLOBS3(MYNUM, MYID) VALUES(1, "STEVE")');
cSQL := 'UPDATE BLOBS3 SET MYBLOB = :BlobParam WHERE MYNUM = 1';
myParams := TParams.Create;
myParams.Clear;
myParams.CreateParam(ftBlob, 'BlobParam', ptInput);
// we will copy the BLOB from a file for testing
// any valid stream should work as source
FileStream := TFileStream.Create('c:localwhatever.exe', fmOpenRead);
myParams.ParamByName('BlobParam').LoadFromStream(FileStream, ftBlob);
FileStream.Free;
SQLConnection1.Execute(cSQL, myParams);
myParams.Free;
end;
var
myParams : TParams;
cSQL : string;
FileStream : TFileStream;
begin
// this just sets up the testing environment
// SQLConnection1 is an open DBExpress TSQLConnection
SQLConnection1.ExecuteDirect('DELETE FROM BLOBS3');
SQLConnection1.ExecuteDirect('INSERT INTO BLOBS3(MYNUM, MYID) VALUES(1, "STEVE")');
cSQL := 'UPDATE BLOBS3 SET MYBLOB = :BlobParam WHERE MYNUM = 1';
myParams := TParams.Create;
myParams.Clear;
myParams.CreateParam(ftBlob, 'BlobParam', ptInput);
// we will copy the BLOB from a file for testing
// any valid stream should work as source
FileStream := TFileStream.Create('c:localwhatever.exe', fmOpenRead);
myParams.ParamByName('BlobParam').LoadFromStream(FileStream, ftBlob);
FileStream.Free;
SQLConnection1.Execute(cSQL, myParams);
myParams.Free;
end;
