Hi Riley,
It looks like you are putting the code into a .dna file, which Excel-
DNA then compiles on-the-fly, giving you those errors.
(The conversion to
VB.NET will probably be easier if you use an IDE
like Visual Studio or SharpDevelop.)
To tell the compiler which additional references you need in the .dna
file, you add some <Reference> tags.
I'm not sure what references are required for the ADO libraries you
want to use.
I'd suggest this:
- Get the code working as a
VB.NET console application (totally
independent of Excel) by starting a new Console project in either
Visual Studio (the
VB.NET Express edition is free) or SharpDevelop,
which is also free.
- Once that part works, we can consider how to implement it in an
Excel add-in.
You're welcome to post here for help getting started with the plain
VB.NET project too, I just want to clearly separate the issues.
----
For easy, high-performance access to data in an MDB, I recommend you
rather use DAO than ADO (for 64-bit support you need the new ACEDAO
libraries).
The pattern for this kind of lookup functino would then be to do a one-
time setup of a Recordset pointing to a table (so use just the table
name instead of a Select query) then set the Recordset.Index to your
lookup index.
Every lookup action then does a Recordset.Seek to position to the
right record from where you return the data.
Following this scheme, simple lookups from a local database should
return at a rate of 20000 - 50000 per second. Over the network it
would be a bit worse, depending on your .mdb size.
But I'd suggest we figure all of this out before integrating with
Excel.
Regards,
Govert