简体   繁体   中英

C# match datagridview rows to access database

I am trying to figure out the best way to match items on a datagridview to items in an access database. (Think Quicken match transaction)

I import an excel sheet into a datagridview,from there it checks the access db looks for a match - if a match is found then it reports match in a column if not unmatched is reported.

i have tried to count the rows on an sql query - if = 1 then match is yes, but that for some reason will goof up sometimes.

so i am looking for the best way to do this.

Thanks - please let me know if you need any additional info.

There isn't a simple answer to this, and it depends on what your data looks like, and what you consider a "match" to be. As a very basic answer, this is one way to attack the problem. How far you take it is up to you...

  • Create an algorithm that takes all fields for a row and generates a "key" for it. For example if there are two fields [First], [Last] then perhaps the key would be "Bubba|Gump"
  • Apply that algorithm to both sets of data (the datagrid records and the access db records).
  • Compare the two sets of keys to determine what's identical/missing/added.

It's not foolproof but with some additional sophistication it'll take you surprisingly far.

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