LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Merge Two Access Databases created with Test Stand

Hello All,

 

I am trying to merge 2 databases using LabVIEW.

When I read the values from the first database some of the numeric fields in the table are NULL.

When I try to write to the second database, those values are being written as 0 if integers and 0.0000 if doubles.

Is there a way to write those values as NULL in the second database if they are Null numeric fields in the first database?

 

 

Thank you in advance,

Stoimen

0 Kudos
Message 1 of 7
(2,257 Views)

Hi stoimenm,

 

Are you merging Access Databases or Excel Databases?  Your title mentioned Access, but I wanted to make sure.  If you are merging Access databases, then you can communicate through the Database Connectivity Toolkit.  If you are trying to merge Excel databases, then you can use the Report Generation Toolkit.  Also, could you give me a little more information about your application.  Are these databases saved to your computer or being created in another application?  I hope this helps!

 

Kim W.

Applications Engineer
National Instruments
0 Kudos
Message 2 of 7
(2,238 Views)

Hi Kim,

They are MS Acces databases. The problem is that when I read the first database data is a variant.When I write to second database , I cast a type to the variant data.

If the data in the first database is numeric, but the field is empty, in the second database value is 0 for that field.

I guess my problem is that there is no such thing as empty numeric field......

Thanks,

Stoimen

0 Kudos
Message 3 of 7
(2,228 Views)

Hi Stoimen,

 

I have been looking into your issue and doing a few tests on my end and it indeed seems like there is no such thing as an empty numeric field. I have found one Knowledge Base article that talks about how to create a blank entry in a LabVIEW array.  I understand that you are using a database, but I am curious if you could enter NaN into those empty numeric fields and get an empty output in your second database value or an output other than a 0. Another idea would be to program some sort of logic into your VI that will output a different value into the entries that were empty (perhaps a "-")?  I hope these ideas help.

 

Kim W.

Applications Engineer
National Instruments
0 Kudos
Message 4 of 7
(2,212 Views)

Hi Kim,

Thanks for the suggestion. I can replace those fields with NaN .

When I read the data as Variant, is there a way to check if the variant is NULL? I have to make that decision before I cast type to the data.

Thanks,

Stoimen

0 Kudos
Message 5 of 7
(2,192 Views)

Hi Stoimen,

 

I am not sure how the flow of your program goes, but you could use the Database Variant to Data to cast the database variant to another type.  This will accept the NULL values from the database and from there you can manipulate them how you wish.  This tutorial may also be helpful in explaining the Database Variant to Data function in LabVIEW, specifically this section: "The null type arises naturally when working with databases (fields in a record are allowed to have null values), so Database Connectivity Toolkit has a special Database Variant to Data function that handles null values, but detecting them requires several steps."

 

I hope this helps!

 

Kim

Applications Engineer
National Instruments
0 Kudos
Message 6 of 7
(2,176 Views)

Hi Kim,

 

Thanks. This is the exact function I am using. The article is a little vague on how the null values are detected. I guess if I figure how to do that, I can insert NaN for the empty numeric fields and empty string for the text fields.

Thanks for all the help!

Stoimen

 

0 Kudos
Message 7 of 7
(2,173 Views)