_Screen.AddProperty([ConnString],[provider=vfpoledb.1;data source=c:\pruebas vfp\fotos\table1.dbf]) cFile = GETPICT("jpg,png,bmp,jepg,tif,tiff") oSt = CREATEOBJECT("ADODB.Stream") oSt.Open oSt.Type=1 &&&& adTypeBinary oSt.LoadFromFile(cFile) Thisform.Coneccion() Thisform.Datos=Thisform.Getrs([Select * From table1 Where Numero=1]) Thisform.Desconectarse Thisform.Datos.AddNew Thisform.Datos.Fields('Foto').Value=oSt.Read() Thisform.Coneccion() Thisform.Updaters(Thisform.Datos,.t.,.t.) Thisform.DesconectarseThis code reads from the table and writes the file back to hard disk
_Screen.AddProperty([ConnString],[provider=vfpoledb.1;data source=c:\pruebas vfp\fotos\table1.dbf]) Thisform.Coneccion() Thisform.Datos=Thisform.Getrs([Select * From table1 Where numero=1]) Thisform.Desconectarse cFile=[c:\pruebas vfp\fotos\foto1.jpg] IF FILE(cFile) ERASE &cFile ENDIF oSt = CREATEOBJECT("ADODB.Stream") oSt.Open oSt.Type=1 &&&& adTypeBinary oSt.Write(Thisform.Datos.Fields('Foto').Value) oSt.SaveToFile(cFile) oSt.Close() Thisform.image1.Picture=cFile Thisform.RefreshConeccion Method (creates an ADO connection)
LPARAMETERS cConnString *--- * Si no se pasa el string de conección como * parámetro se utiliza el string por defecto *--- IF TYPE([cConnString])#"C" cConnString=_Screen.ConnString ENDIF *--- Este Método establece una coneccion ADO This.Conn = Createobject("adodb.connection") With This.Conn .Connectionstring = cConnString .CursorLocation = 3 &&&ADUSECLIENT &&&& 3 .ConnectionTimeOut=60 .Open ENDWITHThis is just an example and can be enhanced, notice the lack of an error management routine and some other stuff.