02-06-2008 02:54 PM
02-06-2008 04:04 PM
02-07-2008 07:28 AM
This has been helpful. I can now write images to the DB and retrieve them to be displayed in LabView. I'm still working on the JPG thing, but I don't think it will be too difficult. I will post what I figure out.
02-07-2008 01:08 PM
10-09-2008 05:16 AM
Hi,
found this thread when i was looking for help on this objective of inserting jpg files into SQL database.
I'm using SQL Express Editiion 2005. I converted the JPEG file into binary string format and try to insert into the SQL database using the database connectivity toolkit. It works however limited to only 8000 bytes of binary string data. I receive this error message when i tried to insert more than 8k bytes.
Exception occured in Microsoft OLE DB Provider for ODBC Drivers: [Microsoft][ODBC SQL Server Driver]String data, right truncation in Rec Create - Command.vi->Cmd Execute.vi->DB Tools Insert Data.vi->Test image file.vi
Can someone advice me what was wrong? and the right approach of using labview to insert the image file? How can I insert the entire JPEG file into the SQL database?
Is there an example program around that prove to be working?
Appreciate greatly for any help given
10-09-2008 07:51 AM
What is the database datatype you are trying to write to? Is the database value's datatype setup to accept more than 8k?
10-09-2008 08:08 AM
hi, i set the datatype in the sql database as image which should be able to hold 0 - 2GB .. i tried changing it to varbinary (max) and i received the same error message.
10-09-2008 08:53 AM
I also hit this limit. In the end I just wrote the JPGs to disk, and stored the file path in the DB. Not the ideal solution, I know.
I'm trying to remember now, exactly what the problem was. You're right to say the image data type should handle up to 2GB. I think in the end, it was an issue of the LabView toolkit not playing well with newer versions of SQL Server, which have the image type. Re-reading the error though, it sounds like it might be an issue with the ODBC driver. FYI, 8KB used to be the max size for the largest types in SQL Server (I think binary in 2000). I suspect this limit was coded into the driver or LabView, and can't handle the newer, larger types.
That being said, the LabView DB toolkit was either written poorly or written a long time ago. It has issues with generating SQL queries that have the proper quotes. For example, if your column names have spaces in them, the toolkit will be unable to generate a valid query, without some modification of the toolkit *.vi's. Images in a database is not a new concept and not new to me. I've never used a language where it was more complicated or difficult to get working. Unless you absolutely have to, I'd work out a way to just store the JPGs to disk, with the path in the DB. Spending too much time on this defeats the purpose of using LabView.
If NI decides to update the DB toolkit, then it might be worth giving it a try again.
In case any NI people are reading this, this is a not so subtle hint that you need to update the DB toolkit to support modern DB features. Especially, if NI is charging $1000 for it.
10-09-2008 11:42 AM - edited 10-09-2008 11:44 AM
Hmmm.
I was going to suggest saving the file to disk, then loading it into the database using the INSERT command, but that still requires an intermediary step using PHP or similar.
10-09-2008 09:07 PM