VBA currentdb

  • Thread starter Thread starter RDA
  • Start date Start date
R

RDA

Hey all,

I'm porting an Access app written in VBA over to C#. I'm curious if
anyone could give me a code block that is equivalent to what is below.
I do not get what the CurrentDb command is "doing" in C# terminology.

CurrentDb.OpenRecordset("SomeAccessTable")

TIA
 
Most of our new development utilizes contemporary DALs. However, given
this is a legacy app, I'd be more than happy to use DAO if need be.
Just getting it out of Access will be a joy.
 
CurrentDB() in Access returns a DAO.Database object for the db where the
code is currently running. It's an object that has the OpenRecordset method
to create and return a DAO.Recordset based on the argument. You showed a
table name, but you can also use a saved query name or a sql statement (in
Access's sql dialect).

Most of our new development utilizes contemporary DALs. However, given
this is a legacy app, I'd be more than happy to use DAO if need be.
Just getting it out of Access will be a joy.
 
Rob,

Using Access is a quiete other way of developing, then developing with C#.

As you use C# against a Jet (official name for what you call Access)
database, then you control what database is used, that is not by Ms-Access
which is build around the use of the tables. As you make programs with C#,
you use tables not the enduser.

Therefore there is no need to tell currentDB. You know what database you are
using and that is not given by the user (or it should be indirect, but even
then he is simple choosing from a list you have given him and you know what
his choise is)

I would certainly avoid DAO in C# as there is only one reason to use it. It
is quicker then the newer ones.
However, a Jet database lacks so much, that the reason to use this should be
that it is simply there.

Afaik is there already no provider for Linq and therefore is probably AdoNet
the best choise.

Cor

Most of our new development utilizes contemporary DALs. However, given
this is a legacy app, I'd be more than happy to use DAO if need be.
Just getting it out of Access will be a joy.
 
Back
Top