osvaldo Posted April 2, 2010 Report Share Posted April 2, 2010 Hi to all, I'm writing an application that use an MS Access database to store test report data... The queries to the database tables and colums are made using the NI Database toolkit. This library returns the data into 2D array of variants, so i've made a VI that try to convert this array (line by line aka record by record) into an 1D array of clusters representing one record each. To do this I'm using the "Variant to Data" node, passing the 1D array of variants as input and specifing the cluster as target type... Well... If I create the 1D array of variants assembling data from controls, the node successfully convert it into the cluster required... If I connect as input the 1D array returned by the Database toolkit, the output cluster results empty! Debbugging the code with probes, I've noted that the data types reported in the variants generated by the toolkit differs from the data types reported for the standard labview types! For example: A column defined as LONG (32 bit integer) in the database file, in the variant returned by the toolkit appear as VT_I4 instead of I32 or U32... Anyone know why this difference? There is a simple metod to automatically convert from the Toolkit type into the standar type variants? I've also try to use the "variant to flattened string" node, but seems that this node does not work whit this kind of variants... Thanks! Osvaldo Quote Link to comment
Rolf Kalbermatter Posted April 3, 2010 Report Share Posted April 3, 2010 For example: A column defined as LONG (32 bit integer) in the database file, in the variant returned by the toolkit appear as VT_I4 instead of I32 or U32... Anyone know why this difference? There is a simple metod to automatically convert from the Toolkit type into the standar type variants? The difference is that the VT_I4 type is an OLE Variant type while the other is a LabVIEW Variant. The Variant to Data used to be able to convert both types but chocked on the VT_NULL Variant that could be returned. For that there was a Database Variant to Data function. It's possible that LabVIEW 8.6 or something changed this behavior so that you do need to explicitly use the Database Variant to Data function from the Database Toolkit palette for all Database Toolkit variants. Quote Link to comment
osvaldo Posted April 6, 2010 Author Report Share Posted April 6, 2010 The difference is that the VT_I4 type is an OLE Variant type while the other is a LabVIEW Variant. The Variant to Data used to be able to convert both types but chocked on the VT_NULL Variant that could be returned. For that there was a Database Variant to Data function. It's possible that LabVIEW 8.6 or something changed this behavior so that you do need to explicitly use the Database Variant to Data function from the Database Toolkit palette for all Database Toolkit variants. Thanks! Can you retrieve the Type Descriptor of these OLE Variant Types using the Variant To Flattened String function? I would like to directly convert a variant array in a given cluster type, as with the original LabView Variant to Data function do. I was unable to convert the array into a cluster directly using the Database Toolkit palette version function... it seems not to handle the aggregate types ... If it were possible to get the type with the type descriptor, I could dismantle the array and rebuild the cluster using the same technique used in OpenG toolkit ... Osvaldo Quote Link to comment
Rolf Kalbermatter Posted April 6, 2010 Report Share Posted April 6, 2010 Thanks! Can you retrieve the Type Descriptor of these OLE Variant Types using the Variant To Flattened String function? I would like to directly convert a variant array in a given cluster type, as with the original LabView Variant to Data function do. I was unable to convert the array into a cluster directly using the Database Toolkit palette version function... it seems not to handle the aggregate types ... If it were possible to get the type with the type descriptor, I could dismantle the array and rebuild the cluster using the same technique used in OpenG toolkit ... Osvaldo I'm afraid the OLE Variants, which the Database Variants really are, do not map 1:1 to the LabVIEW type descriptor definitions so it is very likely that this is not possible. On the other hand the Database toolkit used to have support for parametrized updates and queries so there should be some way, but maybe that got discontinued in the later LabVIEW versions as it was a seldom used feature and likely a pain to support too. Quote Link to comment
osvaldo Posted April 6, 2010 Author Report Share Posted April 6, 2010 I'm afraid the OLE Variants, which the Database Variants really are, do not map 1:1 to the LabVIEW type descriptor definitions so it is very likely that this is not possible. On the other hand the Database toolkit used to have support for parametrized updates and queries so there should be some way, but maybe that got discontinued in the later LabVIEW versions as it was a seldom used feature and likely a pain to support too. Ok! Thanks for all! Have a nice day! Osvaldo Quote Link to comment
Rolf Kalbermatter Posted April 7, 2010 Report Share Posted April 7, 2010 Ok! Thanks for all! Have a nice day! Osvaldo But you should be still able to do what you want by using the DB Tools List Columns.vi to get the column name and datatypes of the query result and according to that info put everything properly into your cluster. Quote Link to comment
osvaldo Posted April 7, 2010 Author Report Share Posted April 7, 2010 But you should be still able to do what you want by using the DB Tools List Columns.vi to get the column name and datatypes of the query result and according to that info put everything properly into your cluster. Oh! This is an idea! I never thought of! Thanks! Osvaldo Quote Link to comment
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.