Graeme Posted October 19, 2010 Report Share Posted October 19, 2010 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. Quote Link to comment
jcarmody Posted October 19, 2010 Report Share Posted October 19, 2010 (edited) 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 October 19, 2010 by jcarmody Quote Link to comment
pete_dunham Posted October 19, 2010 Report Share Posted October 19, 2010 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 Quote Link to comment
Graeme Posted October 20, 2010 Author Report Share Posted October 20, 2010 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. 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.