INSERT AND VIEW IMAGES IN sqlite
Posted: Fri Aug 14, 2015 9:52 pm
Hello wonderful community =).
I had the need to insert images in my database. I think I succeeded, but I can not determine if I did correctly. This is my code to insert (including Sqlite connection, if someone serves you):
When Open the Card:
Now, inside the card I have a button where you select the image and opens in a picture box. Within my "Save" button I have the following code, following the logic of what I want to save is the image that is within my picture box:
Everything is going well with this code, send me the data insersion done properly ... I'm following procedure to insert images are correct? Or what would you recommend? ....
If correct, how could show these images that I picture stored in another box? ... Following the same connection sqlite ....
Thank you very much and best regards!
I had the need to insert images in my database. I think I succeeded, but I can not determine if I did correctly. This is my code to insert (including Sqlite connection, if someone serves you):
When Open the Card:
Code: Select all
on opencard
global ConID
#SE DEFINE LA CARPETA DONDE SE ENCONTRARÁ NUESTRA BASE DE DATOS
put specialFolderPath("Desktop")&"/Herba.sqlite" into tDatabasePath
#CONEXIÓN COMO TAL
put revOpenDatabase("sqlite", tDatabasePath, , , ,) into tDatabasePath
#VERIFICAMOS QUE LA CONEXIÓN NO TENGA ERRORES
put tDatabasePath into ConID #ASIGNAMOS ID DE CONEXIÓN
put "Conexion ID:"& ConID into fld "CID"
put "CREATE TABLE IF NOT EXISTS usuarios (id_usuario integer primary key autoincrement,imagen MEDIUMBLOB);"into tSQL
revExecuteSQL ConID,tSQL
put the result into resultado
if resultado = 1 then
answer info "Se inició la conexión correctamente"
else
answer error resultado
end if
end opencard
Code: Select all
on mouseUp
global conID
put the text of img "image" into tLogo64
put "insert into usuarios (imagen) values (:1)" into tSQL
revExecuteSQL ConID,tSQL, "*btLogo64"
put the result into resultado
if resultado = 1 then
answer info "Se insertaron los datos correctamente"
else
answer error resultado
end if
end mouseUp
If correct, how could show these images that I picture stored in another box? ... Following the same connection sqlite ....
Thank you very much and best regards!