By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,850 Members | 1,026 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,850 IT Pros & Developers. It's quick & easy.

Opening Access db via DAO in vb.net

P: n/a
Hi

In my vb.net app I am trying to open a db via DAO as below;
Imports dao

Dim dbSynch As dao.Database
dbSynch = DBEngine(0).OpenDatabase("C:\MYDB.MDB")
The problem is that on the last line I am getting the error 'DBEngine' is a
type and cannot be used as an expression. What am I doing wrong?

Many Thanks

Regards
Feb 2 '08 #1
Share this Question
Share on Google+
25 Replies


P: n/a
Try:

Dim dbSync As DAO.Database
Set dbSync = OpenDatabase("C:\MYDB.MDB")
--
Arvin Meyer, MCP, MVP
http://www.datastrat.com
http://www.mvps.org/access
http://www.accessmvp.com
"John" <Jo**@nospam.infovis.co.ukwrote in message
news:OI**************@TK2MSFTNGP03.phx.gbl...
Hi

In my vb.net app I am trying to open a db via DAO as below;
Imports dao

Dim dbSynch As dao.Database
dbSynch = DBEngine(0).OpenDatabase("C:\MYDB.MDB")
The problem is that on the last line I am getting the error 'DBEngine' is
a type and cannot be used as an expression. What am I doing wrong?

Many Thanks

Regards


Feb 3 '08 #2

P: n/a
Arvin,

I have tried this one, however I never have used DAO (I used ADO) and could
not get it to work.

I miss this one,
Dim OpenDataBase As New dao.DBEngine

But did not work either.

But the reason that I address this to you, is because of the fact that the
Set will direct be removed from VB2008 when it is typed.

Cor

"Arvin Meyer [MVP]" <a@m.comschreef in bericht
news:eD**************@TK2MSFTNGP06.phx.gbl...
Try:

Dim dbSync As DAO.Database
Set dbSync = OpenDatabase("C:\MYDB.MDB")
--
Arvin Meyer, MCP, MVP
http://www.datastrat.com
http://www.mvps.org/access
http://www.accessmvp.com
"John" <Jo**@nospam.infovis.co.ukwrote in message
news:OI**************@TK2MSFTNGP03.phx.gbl...
>Hi

In my vb.net app I am trying to open a db via DAO as below;
Imports dao

Dim dbSynch As dao.Database
dbSynch = DBEngine(0).OpenDatabase("C:\MYDB.MDB")
The problem is that on the last line I am getting the error 'DBEngine' is
a type and cannot be used as an expression. What am I doing wrong?

Many Thanks

Regards


Feb 3 '08 #3

P: n/a

"Michel Posseth [MCP]" <MS**@posseth.comwrote in message
news:el**************@TK2MSFTNGP02.phx.gbl...
>>What am I doing wrong?
<snip>
2 Is using DAO while it is already a long , long time ago declared
obsolete even in the end of VB6 it was already declared as obsolete
technollogy and ADO was prefered

If you nowadays still use ACCESS in my opinion for new projects you
should not ! but use one of the SQL engines closest to Access is the SQL
CE engine
, e.g. sql server everywhere then you should connect with ADO.Net.

So having said this it is still possible to connect with DAO , however i
will sure not recomend it to you
<snip>

DAO is still the recommended method for accessing data in Microsoft Access
databases if you are using the Jet database engine. Its performance is
significantly better than ADO in this scenario.

Ed Metcalfe.
Feb 3 '08 #4

P: n/a
With all other replies being post, I am just wondering: why on the earth do
you need to use DAO in .NET?
"John" <Jo**@nospam.infovis.co.ukwrote in message
news:OI**************@TK2MSFTNGP03.phx.gbl...
Hi

In my vb.net app I am trying to open a db via DAO as below;
Imports dao

Dim dbSynch As dao.Database
dbSynch = DBEngine(0).OpenDatabase("C:\MYDB.MDB")
The problem is that on the last line I am getting the error 'DBEngine' is
a type and cannot be used as an expression. What am I doing wrong?

Many Thanks

Regards

Feb 3 '08 #5

P: n/a
Well after thoroughly thinking about this question , the answer seems

You don`t

:-)

Or maybe we are both missing something here

Regards

Michel

"Norman Yuan" <Fa******@FakeEmail.Notschreef in bericht
news:O7**************@TK2MSFTNGP03.phx.gbl...
With all other replies being post, I am just wondering: why on the earth
do you need to use DAO in .NET?
"John" <Jo**@nospam.infovis.co.ukwrote in message
news:OI**************@TK2MSFTNGP03.phx.gbl...
>Hi

In my vb.net app I am trying to open a db via DAO as below;
Imports dao

Dim dbSynch As dao.Database
dbSynch = DBEngine(0).OpenDatabase("C:\MYDB.MDB")
The problem is that on the last line I am getting the error 'DBEngine' is
a type and cannot be used as an expression. What am I doing wrong?

Many Thanks

Regards


Feb 3 '08 #6

P: n/a

"Ed Metcalfe" <ed********@hotmail.comwrote in message
news:e%***************@TK2MSFTNGP04.phx.gbl...
>
"Arvin Meyer [MVP]" <a@m.comwrote in message
news:O7**************@TK2MSFTNGP04.phx.gbl...
>At our last MVP Summit in Seattle, we were specifically told by Microsoft
that DAO is the preferred method of dealing with JET and SQL-Server
databases from Access front-ends, reversing decisions made ssome time
ago.

ADO is obsolete, having been replaced by ADO.NET.
>
Is this information published on the Microsoft website anywhere? The most
recent article I could find was this:

http://support.microsoft.com/kb/225048
As you can see, that article hasn't been updated in over 4 years. There may
be some info on the Access Team blog:

http://blogs.msdn.com/access/

I did a cursory search using DAO vs ADO and found:

http://blogs.msdn.com/access/search....DAO+vs+ADO&p=1

which seems to mention several postings by the MS-Access PMs on using DAO in
Access 2007. Sorry I did not do further research, but you're welcome to.
--
Arvin Meyer, MCP, MVP
http://www.datastrat.com
http://www.mvps.org/access
http://www.accessmvp.com
Feb 3 '08 #7

P: n/a
"Michel Posseth [MCP]" <MS**@posseth.comwrote in message
news:uF**************@TK2MSFTNGP06.phx.gbl...
Here comes our difference in perspective ,

You talk as a ACCESS developer , a person who writes solutions completely
in ACCESS , throws in some Access forms and or VBA

I see it from the perspective of a software developer , i just use a DB as
a storage
That, is a huge difference. I can't speak for Ed, but I can tell you that
all I do is write database solutions. Access is not my only tool, but I must
say, that it is uniquely appropriate for database application construction,
if one is building those applications to run on a workstation.

I've been developing databases since 1981, and Access databases since 1992.
I've made living developing databases since 1994. I've been an MVP in Access
since 2000, and also some security related technologies, holding dual MVP
status for 1 year (that's no longer possible).

JET, is definitely not appropriate for all uses. Neither is any database
engine. I do prefer Microsoft engines though, because of the really great
support that Microsoft gives its developer community. That does not mean
that I don't use other technologies, but it does mean that if I'm busy. I'll
sooner turn down jobs that don't use technologies that I can't give my
clients what I feel is the best value for their money. For instance, I refer
all jobs where the Internet may offer a better alternative than the LAN to
other developers. Most of my work is not enterprise wide, although I do lots
of work for government and Fortune 500 clients. For enterprise wide
solutions, Access in not suited for any but the most lightly used
applications. Most of the enterprise apps I see use VB, Java, or .NET
solutions which are not particularly interesting to me because they require
larger teams to build successfully.
--
Arvin Meyer, MCP, MVP
http://www.datastrat.com
http://www.mvps.org/access
http://www.accessmvp.com
Feb 3 '08 #8

P: n/a
"Spam Catcher" <sp**********@rogers.comwrote in message
news:Xn**********************************@127.0.0. 1...
Agreed - Acecss is the way of the Dodo in terms of application
development.
Microsoft has pretty much pigeon holed it into a pure personal desktop
database now.
My clients which include Fortune 500 companies, Federal and local
government, and numerous others will be quite surprised. Departmental and
low user count applications are Access's forte. I do suspect that there are
far more single user Access applications, but the number multi-user apps
runs in the millions.
--
Arvin Meyer, MCP, MVP
http://www.datastrat.com
http://www.mvps.org/access
http://www.accessmvp.com
Feb 3 '08 #9

P: n/a
"Arvin Meyer [MVP]" <a@m.comwrote in
news:O#**************@TK2MSFTNGP05.phx.gbl:
My clients which include Fortune 500 companies, Federal and local
government, and numerous others will be quite surprised. Departmental
and low user count applications are Access's forte. I do suspect that
there are far more single user Access applications, but the number
multi-user apps runs in the millions.
Yes, it "works", butmost developers are only using it because it is what
they're comfortable with. But with all the limitations with Access such as
the threat of DB corruption in a multi-user environment, why not use a real
embedded DB like SQL Compact Edition?

Even Microsoft acknowledges that Access isn't intended to be a general
purposes database engine - rather a personal DB:

http://www.microsoft.com/sql/edition...omparison.mspx

I just don't see the point of using Access anymore when there are better
alternatives out there.
--
sp**********@rogers.com (Do not e-mail)
Feb 3 '08 #10

P: n/a

"Michel Posseth [MCP]" <MS**@posseth.comwrote in message
news:uF**************@TK2MSFTNGP06.phx.gbl...
You talk as a ACCESS developer , a person who writes solutions completely
in ACCESS , throws in some Access forms and or VBA
No, I talk as a developer who uses Access for certain situations. When it is
not appropriate and a better alternative is available then I will pick an
alternative.

Ed Metcalfe.
Feb 3 '08 #11

P: n/a

"Arvin Meyer [MVP]" <a@m.comwrote in message
news:Os**************@TK2MSFTNGP03.phx.gbl...
As you can see, that article hasn't been updated in over 4 years. There
may be some info on the Access Team blog:

http://blogs.msdn.com/access/

I did a cursory search using DAO vs ADO and found:

http://blogs.msdn.com/access/search....DAO+vs+ADO&p=1

which seems to mention several postings by the MS-Access PMs on using DAO
in Access 2007. Sorry I did not do further research, but you're welcome
to.
--
Arvin Meyer, MCP, MVP
http://www.datastrat.com
http://www.mvps.org/access
http://www.accessmvp.com
Thank you. I'll do some further reading tomorrow.

Ed Metcalfe.
Feb 3 '08 #12

P: n/a
Arvin,

DOA and ADO don't really fit in .Net.

You can use it, as you can use as you want probably even a punch card reader
which has drivers for Windows, but therefore a punch card reader is not a
part of Net.

Cor

Feb 4 '08 #13

P: n/a
"William Vaughn" <bi**********@betav.comwrote in message
news:eb**************@TK2MSFTNGP03.phx.gbl...
JET can indeed outperform SQL Server or Oracle or any full-blown DBMS. Of
course it can. It's far, far simpler. A text file can out perform JET.
Just as a screwdriver takes less power to operate than a jackhammer but
can it cut through a foot of concrete? No but, it can be the right tool
for the job--as long as you don't ask too much of it and know how to use
it.

I've seen good Access applications and good Access/JET developers and I've
seen sloppy, ignorant, uninformed and inexperienced developers for every
type of data access paradigm. Customers often can't tell the difference
until it's too late and they have made a career commitment to the
consultant or employee--then it's even harder to purge the old and move
over to a working solution.

I've also seen deadly serious SQL Server applications that should never
have been allowed to run. Good and bad applications are a function of the
developer, the dba, the architect and the people that manage them--not the
tools, engines and Visual Studio. The best tools in the world in
inexperienced hands can still build crap.
We are in total agreement on the above.
--
Arvin Meyer, MCP, MVP
http://www.datastrat.com
http://www.mvps.org/access
http://www.accessmvp.com
Feb 4 '08 #14

P: n/a
No one ever said that either DAO or ADO fit into .NET. The problem posed was
how to get at the data in a JET database using .NET.
--
Arvin Meyer, MCP, MVP
http://www.datastrat.com
http://www.mvps.org/access
http://www.accessmvp.com

"Cor Ligthert[MVP]" <no************@planet.nlwrote in message
news:48**********************************@microsof t.com...
Arvin,

DOA and ADO don't really fit in .Net.

You can use it, as you can use as you want probably even a punch card
reader which has drivers for Windows, but therefore a punch card reader is
not a part of Net.

Cor

Feb 4 '08 #15

P: n/a
On Sun, 03 Feb 2008 21:27:15 GMT, Spam Catcher <sp**********@rogers.comwrote:

"Arvin Meyer [MVP]" <a@m.comwrote in
news:O#**************@TK2MSFTNGP05.phx.gbl:

My clients which include Fortune 500 companies, Federal and local
government, and numerous others will be quite surprised. Departmental
and low user count applications are Access's forte. I do suspect that
there are far more single user Access applications, but the number
multi-user apps runs in the millions.

Yes, it "works", butmost developers are only using it because it is what
they're comfortable with. But with all the limitations with Access such as
the threat of DB corruption in a multi-user environment, why not use a real
embedded DB like SQL Compact Edition?

Even Microsoft acknowledges that Access isn't intended to be a general
purposes database engine - rather a personal DB:

http://www.microsoft.com/sql/edition...omparison.mspx

I just don't see the point of using Access anymore when there are better
alternatives out there.

I think you need to define what you mean by "better". Better for what?

SQL CE has its own set of limitations so it's not always a viable candidate. It lacks any user
interface (from which to create ad-hoc reports or queries) and there is no concurrent multi-user
support.
Paul
~~~~
Microsoft MVP (Visual Basic)
Feb 4 '08 #16

P: n/a
"Norman Yuan" <Fa******@FakeEmail.Notwrote in message
news:ui**************@TK2MSFTNGP03.phx.gbl...
Which is better,ADO.NET, ADO, or DAO? in many or most cases it depends on
the concrete situation, how the data is accesses/used, rather than the
technology the developer choose without fully familiar with all available
options. There is surely some situation, using purely DAO would get you
the best performance to the application.
True
So, the question is, if you have to use DAO, why take a round trip from
.NET COM interop? Go with VB5/6 and make things simpe and straighforward.
Usually, the prudent path is to use the technology you are already working
with. Why would anyone who is building a .NET app which needs to get some
data from a JET database, go with VB5 or VB6? If I were building a small
utility, I might consider using VB6, but not if I were building a database
centric app of any kind. If it was a local app (i.e. run on a LAN), I'd use
an Access front-end, and if it were an Internet app, I'd use either asp, or
more likely the .NET framework.

The gist of this thread, before it got side-tracked is which technology to
use with JET. That is almost always DAO. Like-wise ADO, or ADO.NET is
usually used with SQL-Server depending upon the front-end.
--
Arvin Meyer, MCP, MVP
http://www.datastrat.com
http://www.mvps.org/access
http://www.accessmvp.com
Feb 4 '08 #17

P: n/a
Ah, you can use the RDL-based ReportViewer with SQLCe as well as the VS
Query Builder tools to build queries.

--
__________________________________________________ ________________________
William R. Vaughn
President and Founder Beta V Corporation
Author, Mentor, Dad, Grandpa
Microsoft MVP
(425) 556-9205 (Pacific time)
Hitchhiker's Guide to Visual Studio and SQL Server (7th Edition)
__________________________________________________ __________________________________________
"Paul Clement" <Us***********************@swspectrum.comwrote in message
news:lp********************************@4ax.com...
On Sun, 03 Feb 2008 21:27:15 GMT, Spam Catcher <sp**********@rogers.com>
wrote:

"Arvin Meyer [MVP]" <a@m.comwrote in
news:O#**************@TK2MSFTNGP05.phx.gbl:

My clients which include Fortune 500 companies, Federal and local
government, and numerous others will be quite surprised. Departmental
and low user count applications are Access's forte. I do suspect that
there are far more single user Access applications, but the number
multi-user apps runs in the millions.

Yes, it "works", butmost developers are only using it because it is what
they're comfortable with. But with all the limitations with Access such
as
the threat of DB corruption in a multi-user environment, why not use a
real
embedded DB like SQL Compact Edition?

Even Microsoft acknowledges that Access isn't intended to be a general
purposes database engine - rather a personal DB:

http://www.microsoft.com/sql/edition...omparison.mspx

I just don't see the point of using Access anymore when there are better
alternatives out there.

I think you need to define what you mean by "better". Better for what?

SQL CE has its own set of limitations so it's not always a viable
candidate. It lacks any user
interface (from which to create ad-hoc reports or queries) and there is no
concurrent multi-user
support.
Paul
~~~~
Microsoft MVP (Visual Basic)
Feb 4 '08 #18

P: n/a
Michel,

I don't think that we should bring the knowledge of any body involved in
this messagethread in discussion and the last who deserves that is Alvin.

He comes with real points, that we don't agree from our point of view is
maybe something else, however I am interested to be able to look at it from
his point of view.

Cor

Feb 4 '08 #19

P: n/a
"Arvin Meyer [MVP]" <a@m.comwrote in
news:eW**************@TK2MSFTNGP02.phx.gbl:
I'm really sorry that you think that Access/JET is a single-user
database. You're obviously missing giving some of your users a fast,
easily maintainable solution.
Microsoft thinks so too! Have you read their recent whitepapers? :-)

--
sp**********@rogers.com (Do not e-mail)
Feb 4 '08 #20

P: n/a


Well if anybody has read in my messages that i question anybody`s knowledge
well in that case my humble apolygees
this is and was never my intention .

For me this was just a welcome and sharp discussion , and indeed with Arvin
and Ed i do not share there opinion on certain things

Michel

"Cor Ligthert[MVP]" <no************@planet.nlschreef in bericht
news:64**********************************@microsof t.com...
Michel,

I don't think that we should bring the knowledge of any body involved in
this messagethread in discussion and the last who deserves that is Alvin.

He comes with real points, that we don't agree from our point of view is
maybe something else, however I am interested to be able to look at it
from his point of view.

Cor

Feb 4 '08 #21

P: n/a
"Spam Catcher" <sp**********@rogers.comwrote in message
news:Xn**********************************@127.0.0. 1...
"Arvin Meyer [MVP]" <a@m.comwrote in
news:eW**************@TK2MSFTNGP02.phx.gbl:
>I'm really sorry that you think that Access/JET is a single-user
database. You're obviously missing giving some of your users a fast,
easily maintainable solution.

Microsoft thinks so too! Have you read their recent whitepapers? :-)
Microsoft thinks that a million rows and 4000 columns are reasonable limits
for spreadsheets too. Have you seen Excel 2007?
--
Arvin Meyer, MCP, MVP
http://www.datastrat.com
http://www.mvps.org/access
http://www.accessmvp.com
Feb 5 '08 #22

P: n/a
I don't expect they do, but their customers seem to think that's necessary.

--
__________________________________________________ ________________________
William R. Vaughn
President and Founder Beta V Corporation
Author, Mentor, Dad, Grandpa
Microsoft MVP
(425) 556-9205 (Pacific time)
Hitchhiker's Guide to Visual Studio and SQL Server (7th Edition)
__________________________________________________ __________________________________________
"Arvin Meyer [MVP]" <a@m.comwrote in message
news:OP**************@TK2MSFTNGP06.phx.gbl...
"Spam Catcher" <sp**********@rogers.comwrote in message
news:Xn**********************************@127.0.0. 1...
>"Arvin Meyer [MVP]" <a@m.comwrote in
news:eW**************@TK2MSFTNGP02.phx.gbl:
>>I'm really sorry that you think that Access/JET is a single-user
database. You're obviously missing giving some of your users a fast,
easily maintainable solution.

Microsoft thinks so too! Have you read their recent whitepapers? :-)

Microsoft thinks that a million rows and 4000 columns are reasonable
limits for spreadsheets too. Have you seen Excel 2007?
--
Arvin Meyer, MCP, MVP
http://www.datastrat.com
http://www.mvps.org/access
http://www.accessmvp.com
Feb 6 '08 #23

P: n/a
"William Vaughn" <bi**********@betav.comwrote
I don't expect they do, but their customers seem
to think that's necessary.
I know: The customer isn't always right, but, if the bills get paid, it's
the customer who pays them.

Even so, with the Mighty Microsoft Marketing Machine's golden tongues and
the Mighty Microsoft Development and Support Machine's golden abilities, it
would seem that Microsoft could have educated their customers instead of
giving them a large coil of rope with which to hang themselves.

I'm surprised, Bill, to hear this from someone who's sufficiently concerned
about the quite stable, proven, and eminently usable Jet database engine
that he thinks Microsoft ought to abandon it (for which read: take it away
from their customers) and replace it with SQL Server. (I would hope you also
think that they need to improve SQL Server <whatever editionso that, to
the end-user, it is equally as seamless to use as is Jet.)

Larry Linson
Microsoft Office Access MVP

Feb 7 '08 #24

P: n/a
Arvin makes some excellent points that are often lost on internal
folks at msft, especially the SQLS team.

Bear in mind that each product team produces its own whitepapers in
the hopes that providing detailed information about their product will
not only help customers create successful solutions, but also increase
the revenue stream for their product. Consciously or unconsciously,
bias often creeps in, and in the case of the long-running Access/SQL
feud, there has been a tendency to showcase the failure cases when
Access was used inappropriately while ignoring the silent evidence of
its spectacular success in creating real-world applications with a low
TCO.

So when reading whitepapers, it helps to keep an open mind and
consider the source. The following paper was written by the president
of FMS (an ISV creating Access/SQLS tools) and vetted by a member of
the SQL Server team:

Microsoft Access or SQL Server 2005: What's Right in Your
Organization?
http://www.microsoft.com/sql/solutio...or-access.mspx

This one was written by an MVP and vetted by both the Access and SQL
Server teams:

Optimizing Microsoft Office Access Applications Linked to SQL Server
http://msdn2.microsoft.com/en-us/library/bb188204.aspx

Hope this helps shed some light on the subject while damping down the
heat :)

--Mary

On Mon, 04 Feb 2008 18:44:49 GMT, Spam Catcher
<sp**********@rogers.comwrote:
>"Arvin Meyer [MVP]" <a@m.comwrote in
news:eW**************@TK2MSFTNGP02.phx.gbl:
>I'm really sorry that you think that Access/JET is a single-user
database. You're obviously missing giving some of your users a fast,
easily maintainable solution.

Microsoft thinks so too! Have you read their recent whitepapers? :-)
Feb 7 '08 #25

P: n/a
To run synchronising on the backend db which is a replicated access database

"Norman Yuan" <Fa******@FakeEmail.Notwrote in message
news:O7**************@TK2MSFTNGP03.phx.gbl...
With all other replies being post, I am just wondering: why on the earth
do you need to use DAO in .NET?
"John" <Jo**@nospam.infovis.co.ukwrote in message
news:OI**************@TK2MSFTNGP03.phx.gbl...
>Hi

In my vb.net app I am trying to open a db via DAO as below;
Imports dao

Dim dbSynch As dao.Database
dbSynch = DBEngine(0).OpenDatabase("C:\MYDB.MDB")
The problem is that on the last line I am getting the error 'DBEngine' is
a type and cannot be used as an expression. What am I doing wrong?

Many Thanks

Regards


Feb 13 '08 #26

This discussion thread is closed

Replies have been disabled for this discussion.