04-19-2017 08:03 AM - edited 04-19-2017 08:10 AM
Hi everyone !
I'm posting here because I'm really stuck at this moment on a apparently very simple matter.
I'm establishing a connection with a database, and writing data in a table, this table has 4 columns.
After writing some random data, I'm displaying those by using the "Select Data" VI, and it works great, unless I'm dealing with Decimal(20,0) datatypes..
I have really no idea from where it could come from.
I tried modifying the input type (as strings for example) before bundling the cluster of data being sent to the database, without any result.
Maybe there's a trick I'm missing here !
Thank you for your help !
Solved! Go to Solution.
04-20-2017 07:55 AM
Hey,
could you provide your VI to better understand the issue.
Did you test to read decimal data manually written to the database to varify it's a reading and not a writing error?
04-20-2017 09:00 AM - edited 04-20-2017 09:06 AM
Hi ! Thanks for your reply !
By using the "Database Variant To Data Function" ( http://zone.ni.com/reference/en-XX/help/370016E-01/lvdatabase/database_variant_to_data/ )from the database toolkit, I actually managed to display my data correctly. (see next picture)
The problem looks like to be in the output data from my database which is given to me after using the SELECT function.. I have to convert it to make my numbers (the first two item of the sent cluster) displayable (but the date and the varchar can be directly displayed)
I could upload the VI but I need to remove some sensitive data first ^^.
But still, it looks like the data were correctly written since they're displayable after this "Variant To Data Function"..
Now I'm just wondering if I could skip this step or if it's definetly necessary !
And by the way, the first two columns in my database table are DECIMAL(20,0), so I first tried to send them as simple integers (on labview) in my cluster.. like this
but it didn't change anything..
04-20-2017 09:16 AM
http://home.hit.no/~hansha/documents/software/documents/DCT_User_Manual.pdf
Page 32 shows exactly what I'm trying to do.. and it seems to work in their example.
Hmmm
04-24-2017 04:00 AM
I just tested it with an .mdl database and it worked. Could you provide some minimal example code with a small database that I can check your issue.
04-24-2017 10:10 AM
I often use a typdef cluster to define the data inserted or selected from a database.
Some time ago, I created a VI that uses a scripting function to read the structure of a table and create a cluster.
Run this, save the resulting cluster as a typedef, then use it as the prototype to the "Database Variant to Data" function.
If you change your database table structure, you would need to update/replace the typedef.
https://forums.ni.com/t5/LabVIEW-APIs-Documents/DB-Tools-Create-Cluster-from-Table-vi/ta-p/3516670
04-25-2017 06:58 AM
That's a great solution !
However, converting the data with "Database Variant to Data" from the DB Toolkit solved my issue.. considering the relative small size of my database, that should do the trick.
I'll keep your solution in mind nonetheless, it could be useful in the future !