简体   繁体   中英

Reading and matching data from Excel/Access using C#

For the past few months I have been making a testing kit for one of the products at our company which requires the programming of a micro-controller. The actual tester itself is working correctly, but my problem is interfacing with a set of values from a database in order to correctly set the tester.

This is what id like to do.

  • read a value, say "resistance"

  • send the value to the tester

  • then using the value that returns from the tester, match it up with a second set of data, say "current"

  • if the current matches then move on to the next resistance.

The core program for sending and receiving values from the controller is working but requires the user to input the "resistance" value then manually read the current value.

I was wondering what was the best way to achieve this.

The core program is written in C#.

Should I write something in VBA inside the Access database and have it exchange values with the C# program? If so, how would I send the value from the Access VBA code to the C# program and visa versa?

Thanks,
Adam

Rather than fuss around with getting Access VBA code to "talk to" your C# program you could simply add code to the C# program to read test values from a table, send the values to the controller, and check the results that the controller returns. If you do some searching here in Stack Overflow you will find lots of examples of how to achieve this.

As a nudge in the right direction, you might want to look for questions that use OleDbConnection , OleDbCommand , and OleDbDataReader objects (which are all part of System.Data.OleDb ) to perform operations on an Access database ( .accdb or .mdb file).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM