Jump to content

Display images from A database


Recommended Posts

LabVIEW 2013 

SQL Server 2012

 

I would like to read an image path from a SQL database and display the image on the front panel in LabVIEW. The database side works ok but when I run the VI i get an error saying Error 7 file not found. I have checked the directory and the path is correct. I have attached a screenshot of the VI and error.

post-51482-0-73684800-1397119322_thumb.p

post-51482-0-73761700-1397119327.png

Link to comment

Go ahead and type in that path on your windows machine into Run or the Explorer path.  I'm guessing that it won't work because your path contains spaces between each character, some non printable characters, and characters before the drive letter.  Looks like something went wrong with your read and conversion to a path.

Link to comment

I have checked the string in the windows explorer the path works ok. C:UsersconorDesktopLabview DemosDatabase GeneratorImagesFilm3 that is the current path but when its read from the database it puts in those extra symbols.The string is stored as a varchar(max) in the database to hold the paths to the images. 

Link to comment

You are forcing LabVIEW to interpret a 2D array as a string. It isn't. It's a 2D array and because you are unflattening, you are getting ll the array index info in the string..

Use the index array to obtain a single element from the array returned by the SELECT function. Then use the Variant to Data primitive to convert it to a string.

 

Unflattening requires that the data was stored as flattened to begin with. I expect it wasn't.

  • Like 1
Link to comment

Hi ShaunR thanks for your reply when I insert the index array vi and run it I get error 91 occured at variant to data in my vi name.

 

Possible reason(s):

 
LabVIEW:  The data type of the variant is not compatible with the data type wired to the type input.

 

Without knowing how the data got stored into the database first, it will be very hard to come up with a good idea. Was the path flattened and then stored as string?

You basically have to reverse that operation exactly to have any chance of getting a sensible result. The idea about using index array from Shaun is however definitely the first step in this. Your query returns an array of values and you want to get the single value in the query result first before you do any other manipulation to get back at your path.

Link to comment
  • 2 weeks later...
I have checked the string in the windows explorer the path works ok. C:UsersconorDesktopLabview DemosDatabase GeneratorImagesFilm3 that is the current path but when its read from the database it puts in those extra symbols.The string is stored as a varchar(max) in the database to hold the paths to the images. 

 

If you change the data type of this field in the database to nvarchar(max) do you still get the same issue ? 

 

If you set a field to be varchar(x) then the string stored there will be x in length even if the string originally stored was shorter. When you query the database you will get back a string of length x. Using nvarchar will store a variable length string up to length x.

Link to comment

post-51645-0-19614800-1398117802_thumb.p

 

If you flattened the data going into the DB you will want to unflatten it coming out.

 

If you set the condition on the select exactly one element, you can index 0,0 of the 2d array and have your specific img. 

Edited by drakhri
Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.