Jump to content

Writing to MS Access table via ActiveX


Recommended Posts

Hi all,

I post this with a little trepidation as I'm sure I'll get shot out of the Ether as this must be one of the most common LabVIEW ActiveX questions asked. However, try as I might I can find no hint to the solution anywhere. I've Googled this and searched LAVA posts and code repository but to no avail. In general there's a lot about Excel but not much on Access.

All I want to do is add a record (row) to the end of an MS Access database table. I know the path to the database and I know the table name. I found a lovely example somewhere on ni.com that reads an entire Access table into LV via ActiveX. Beautiful! I thought I'd chop the back end read stuff off of this and replace it with appropriate write functions. My problem is I can find no properties or methods anywhere down the ActiveX Access application hierarchy that seem do this. You want to know the number of fields, records and all sorts of other stuff - no problem. But adding records, setting or changing values of something - I can't even get started. Is there anyone who is able and willing to point me in the direction of enlightenment on this one?

Regards.

Link to comment

Here are two ADO DB toolkits that might give you a place to start.

http://www.ib-berger...tion=adotool_en (this links to MS' ADO Programmer's Guide http://msdn.microsoft.com/en-us/library/ms807642)

http://jeffreytravis...ost/labsql.html (this one appears to be older)

Jim

Edited by jcarmody
Link to comment

All I want to do is add a record (row) to the end of an MS Access database table. I know the path to the database and I know the table name.

I have some code that does just this. You need to "send in" the Field names as created in your table (ADO doesn't like spaces).

I usually use this subVI to add in one field at a time to see if I can write values.

Remember, that you have to use a different method to add/replace fields to a row thats already created (this is an UPDATE action).

I have attached the code.

LAVA woudln't let me upload sample database but included a screenshot. The created database in screenshot worked with the subVI included.

Good luck and let me know if I can help.

-Pete

Write Row Into Database example.vi

post-15321-092053700 1287522872_thumb.pn

Link to comment

Thank you for the replies so far. Pete, your code is just what I was looking for and I'm having fun playing around with it. Thanks. Replacing a space in a field name with an underscore didn't work for me. However, digging around microsoft.com suggested putting such names in square brackets. This did the trick and works for table names as well. Looks like ADO is something I need to get familiar with.

Regards.

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
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
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.