0

I'm upgrading an old VB6 application to VB.NET that uses DAO to connect to an Access database. I know that this is a hopelessly outdated technology, but considering the amount of work changing to ADO, I've decided to stay with DAO, despite the frustration trying to find documentation.

My problem is that I'd like to have a DataGridView reflect a table from the database. Of course I could make my own routine manually setting the columns and fill the DataGridView, but if it is a way, I'd like to use the DataSource property or some other built-in function. I found a forum post that looked promising, but unfortunately I couldn't find the attachment that was referred to.

Also, if there are other controls better suited for this than the DataGridView, please let me know.

Thanks

MarkJ
  • 30,070
  • 5
  • 68
  • 111
joharei
  • 578
  • 1
  • 5
  • 22

2 Answers2

1

DAO documentation isn't hard to find. Install VB6 and the Microsoft Developer Network (a disk was bundled with VB6). Go into the VB6 IDE, view your code, put the cursor on a DAO keyword, press F1. Presto - helpful documentation! If you prefer an online reference, the DAO documentation from Access 2007 should meet your needs very well.

So you want to bind a DataGridViewTable to a DAO table? Nice idea, but it's a big ask. Did the VB6 app use data-binding?

  • If it did, you're going to have a hard time migrating that to VB.Net. Consider shifting to ADO.Net in the VB.Net replacement.
  • If it didn't, you might be able to use DAO from VB.Net via COM and you might find that the DAO-related VB6 can be ported to DAO-related VB.Net without much effort. I don't know.
MarkJ
  • 30,070
  • 5
  • 68
  • 111
0

One option would be to use a method found in Code Complete. Put a nice, clean layer between the VB.NET user interface and the legacy data access code (your DAO code). The layer would take the data fetched via DAO and transfer it into a DataTable object. Then, you send the DataTable to the UI and use it as the .DataSource property of the DataGridView.

Honestly, however, since this involves writing code for each DAO function that returns data for you to display, I would just refactor your data access routines into ADO.NET. Since DAO is so, so, so old, in my opinion it would be irresponsible to be creating a "new" application and using such outdated technology, even though it technically can "work".

HardCode
  • 6,497
  • 4
  • 31
  • 54
  • I decided to use the data binding wizard in Visual Studio and do a more thorough replacement of the old stuff. Tired of the backwards engineering required to make use of DAO ;) – joharei Jul 03 '12 at 08:59