f



How to add records with 'Autonumber' property to a MS Access database using LabVIEW?

I am trying to write to a MS Access database. Everything works fine as
long as I add data to all records at the same time.
The database I am using have two tables (just for testing) with a
'one-to-many' relationship between the two. They both have a
PrimaryKey with the data type 'AutoNumber'. From what I understand
those numbers should be automatically generated when new data is
written to the DB. I can't get that to work with LabVIEW.
I am using the function 'DB Tools Insert Data.vi'. According to the
manual I should be OK with specifying the column I want to write to.
If I specify all columns it works just fine but then the value of the
'PrimaryKey' is not Autogenerated.

I get this error when not all columns are specified:
'Error -2147217900 occurred at Cmd Execute.vi->DB Tools Insert
Data.vi->db_test.vi'

Can anyone help me figure out the 'AutoNumber' mystery?
0
x9561 (148442)
1/6/2004 5:06:17 PM
comp.lang.labview 35213 articles. 1 followers. vasusachin24 (1) is leader. Post Follow

6 Replies
1091 Views

Similar Articles

[PageSpeed] 24

I'm not exactly sure what you mean by it not working. It would be good
for you to attach an example including the database and the VI. I
tried this with a simple example and it worked fine.  Make sure the
array of field names doesn't contain the name of the autonumber field.
Also, that error is a generic syntax error.  Look at the names of the
fields and make sure they do not have spaces in the names or don't use
reserved words.  Use the underscore character in field names instead
of spaces.

Crystal
0
x9561 (148442)
1/6/2004 6:15:51 PM
I need to make a correction.
You need to make a new udl file that points to the db in order to get
it to work.
Sorry about that!

:-)
0
x9561 (148442)
1/6/2004 8:39:38 PM
It seems to be working fine now. Thank you. How did you find this out?
I searched everywhere and found nothing.
Why does it work when you take out the autonumber field but it desn't
work if I don't provide it from the start?

Anyhow, thank you again for solving my problem.
:beer; for you and a Happy New Year.
:-)
0
x9561 (148442)
1/6/2004 10:21:38 PM
Hi Crystal,

I would like to humbly request that you become an enthusiast
(technically I beleive you would qualify as an "Expert"). This would
allow us to subscribe to your answers and recieve automatic updates
whenever you post an answer or a response.

S-Man,
"How did you figure this out?" I believe this is the same "Crystal"
that wrote the original LV SQL tool kit.

Ben
0
x9561 (148442)
1/7/2004 1:33:12 PM
Hi, Ben

Thanks for your comment, I'm flattered.  I honestly don't know how one
gets marked as an "enthusiast" but I am on the LabVIEW R&D team and
the Database Connectivity Toolset is one of the products I'm
responsible for.  (The original SQL Toolkit was written by an alliance
member many years ago and is no longer supported.)  The world of
databases isn't trivial and I try to help when I can.

Thanks again,
Crystal
0
x9561 (148442)
1/7/2004 4:02:59 PM
That explains it! :)

I'd like this to be better documented in the LV Manuals. I looked
everywhere but couldn't find anything about my problem.
0
x9561 (148442)
1/7/2004 5:16:33 PM
Reply: