Save images to sqlite database
Posted
#1
(In Topic #1574)
Trainee

am new this forum
I want to know how to save image to sqlite database from Picturebox.Picture
I tried this method. but it is not stored as a image
If Not IsNull(picChart.Picture) Then
bb = Byte[].FromString(picChart.Picture.ToString())
cnnFile.Exec("update userdata set indeximage = '" & bb.tostring() & "' where dateid = " & dtid)
Endif
Is there any solution to solve the issue. I want to save image from picturebox to sqlite and retrive back the data and display in picture box
I request you to kindly help me to solve the issue
Regards
Rajeev
Posted
Banned
I do not know much about database access but If it must be utf-8 string then maybe use Base64
To read it back use FromBase64
Posted
Banned
Images converted to strings can mean a lot of excessive database data making slower reads.
Posted
Regular

However 1) if the images tend to be permanent or fairly permanent and a strategy can be built to minimize the loads say for a company logo that is retrieved at program startup or something similar then there is nothing inherently evil about keeping them in the database. Even in the case of say a graph image that is updated once a day, say yesterdays sales totals, then with care the use of database stored images can be relatively efficient and has the extra advantages of dbms backups etc.
2) (as usual rant) sqlite is NOT an efficient database management system. It is absolutely fine for casual or exploratory use but is not suitable for a high use transactional system. PostgreSQL or MariaDB provide much better performance (and features). But then if you are looking for a SMALL database to store SMALL images (lets say icon sizes) then it is …. ok … but the others are better.
regards
thatbruce
Posted
Trainee

actualy, the image size is below 100 kb. sqlite is better for my small application.
storing the image in device storage is not practical.
anyway i will try base64 frombase64 func
thank u
Posted
Trainee

Now its working. and my problem is solved.
thank you Mr. BruceSteers and thatbruce
1 guest and 0 members have just viewed this.





