LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Retrieve Pictures from Access Database w/LabSQL

So you took the picture, encoded it, and stored that info into the table?  The only reason I was using BMPs instead of JPEGs is that I was told databases handle them better (I forgot where I read that).  I would like to keep this whole process as fast and efficient as possible.  I am more concerned with speed than with file size.  Does the encoding/decoding process take a long time?
 
Anyway if you could write a VI that can load a picture from a file, encode it, write it to a table, then retrieve it, decode it and display it... that wouldbe great, I could tailor this for what I need done.
0 Kudos
Message 11 of 18
(807 Views)
Here's the VI I was working with.  It's set up to work with PNG files instead of BMPs because my database doesn't like anything bigger than 1M.  I assume that would be easy enough to change it so that it uses BMPs, but I wouldn't recommend doing so.

Also remember to change the connection string back to whatever you were using before.


Message 12 of 18
(797 Views)
I tried running your code but I got an error on creating the temporary file.  I couldn't work my way around it.  I got the same result as with my old code... that is the first columns had the IDS, and the 2nd & 3rd columns were blank.  I will try and work this out tommorrow morning.  I am wondering if there is an easier way to accomplish what I need done.  All I need to do is be able to store 2 pictures in some sort of database and retrieve that info later.  The only way I could think of doing this was by creating a table with 2 pictures per record in a database.  Can anyone think of any other solutions?
0 Kudos
Message 13 of 18
(795 Views)
Did you set the fields to hold text instead of binary data?

Did you erase the old records and use the code I sent to put the pics into the database? Could you see the data from Access?

As for other solutions, did you consider just saving the pictures as files?  I don't know what would be approprioate for your application, but you could just save all of your XY_graphs in one directory and all of your YZ_graphs in another.  Then XY_graph/001.png would correspond to YZ_graph/001.png and so on.  The other obvious solution would be to use one directory per set of images, so for ID#1, the XY would be saved in graphs/001/XY.png and the YZ would be in graphs/001/YZ.png.
Message 14 of 18
(789 Views)
One more thing.  I have Access on my laptop at home, so I tried a couple of things.  First, it looks like there's no way to store arbitrarily large fields.  The best I could do was use a memo field that holds up to 64k (because of the encoding that means the image has to be smaller than 32k).

Also, once I created the table and set the correct connection string ("Driver={Microsoft Access Driver (*.mdb)};Dbq=c:\somepath\mydb.mdb;"), it started working right away.  Maybe some of your changes in the "ODBC thingie" are causing trouble.
Message 15 of 18
(785 Views)
I deleted the table and created a new one with two text strings.  The first time I ran the code I got an error on the write to binary file.  The 2nd I got an error on the open/create/replace.  THe VI didnt execute the close/delete because of the error and so.. the temp file was not deleted.  I tried to delete manually it gave me an error... it said another program was still using the file.  I think it didnt let me open/create on the 2nd run since it didnt execute the close/delete file VIs in the 1st run.
 
I opened the database in access and it has some text, but not the complete strings only the first few characters, maybe 20 or 30.  You said you got yours working on access so I dont see why my access would have the text field limitation and yours wouldnt.
0 Kudos
Message 16 of 18
(777 Views)
I changed the data type from text to memo and changed the name of the temp file and that fixed it.  Thanks A LOT for all your help and patience.  I will not try and do what I was actually trying to do originally, if I have any other problems, I will post them here.
0 Kudos
Message 17 of 18
(774 Views)
I noticed the code kept taking longer and longer to run when I added more pictures.  It looks like it is decoding all the pictures and then displaying only one of them.  I modified it to where the user selects the row to be displayed.  I tried to modify it to where only the selected row is decoded and got errors.  Is this possible or does the whole table need to be decoded?
0 Kudos
Message 18 of 18
(749 Views)