LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Save PNG file to SQL server

I'm trying to save a png image (front panel image or chart image) to SQL server image field or varbinary(max) field directly but couldn't make it like mentioned in this article

http://zone.ni.com/devzone/cda/epd/p/id/5210

A simple binary file is okay to save but not an image file either in the format of "image data" or "png data".

Anyone familiar with the subject can give some suggestions? Thanks in advance.

0 Kudos
Message 1 of 6
(5,536 Views)

Are you trying save directly as a parameter of SQL Instrucion (insert into or update)? If yes, you need escape special characters. Like " (double quotes).

Refer to SQL Server special characters. For my case I'm using this function to escape characters to MySQL instructions.

Message 2 of 6
(5,505 Views)

 Hi bruno_costa,

 

Thanks for your respond to my post. It looks very reasonable to add the escape procedures, but after adding it, I still couldn't make it through. The following is the error, the error code of -2147217887 is endefined. Also, I haven't found the ADO Error of 9x80040E21 which will fit my case yet.

 

NI_Database_API.lvlib:Cmd Execute.vi->NI_Database_API.lvlib:DB Tools Insert Data.vi->save png - Copy.vi<ERR>ADO Error: 0x80040E21

Exception occured in Microsoft OLE DB Provider for ODBC Drivers: [Microsoft][ODBC SQL Server Driver]String data, right truncation in NI_Database_API.lvlib:Rec Create - Command.vi->NI_Database_API.lvlib:Cmd Execute.vi->NI_Database_API.lvlib:DB Tools Insert Data.vi->save png - Copy.vi

 

Guangde

0 Kudos
Message 3 of 6
(5,495 Views)

Isn't there some 8k limit to the sql string?

/Y

G# - Award winning reference based OOP for LV, for free! - Qestit VIPM GitHub

Qestit Systems
Certified-LabVIEW-Developer
0 Kudos
Message 4 of 6
(5,487 Views)
Yamaeda is correct. There are a limit for max packet. In mysql I set this to 200M.
0 Kudos
Message 5 of 6
(5,481 Views)

For SQL Server Express, there are varbinary(max) and image data types which will not have the limitation of 8k. Please check the following link:

 

http://msdn.microsoft.com/en-us/library/ms188362.aspx

 

Still the size or type is a factor here, for the VI, I can send an ordinary string to the table but not a png file.

0 Kudos
Message 6 of 6
(5,463 Views)