473,412 Members | 2,072 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,412 software developers and data experts.

Unable to establish connection to Access database via code

I am trying to establish a connection to an Access 2003 database I have
stored locally on my C:\ drive. However, everytime I try to run my code I get
the following error message.

An unhandled exception of type 'System.Data.OleDb.OleDbException' occurred in
system.data.dll

I've looked at several resources and have seen similar code. What am I
overlooking?

Private Sub btnLoad_Click(ByVal sender As System.Object, ByVal e As System.
EventArgs) Handles btnLoad.Click
Dim dataset2 As New DataSet
dataset2 = New DataSet("dataset2")
Dim ConnectionString As String = "Provider=Microsoft.Jet.OLEDB.4.0;
Data Source = C:\AutoCAD Project\AutoCAD Files.mdb; User ID=Admin"
Dim Connection1 As OleDbConnection = New OleDbConnection
(ConnectionString)
Dim Command1 As OleDbCommand = New OleDbCommand("SELECT * FROM
AutoCAD Files", Connection1)

Connection1.Open()
Command1.Connection = Connection1

Dim daAdapter1 As OleDbDataAdapter = New OleDbDataAdapter

daAdapter1.SelectCommand = Command1
DataGrid1.Visible = True
daAdapter1.Fill(dataset2, "AutoCAD Files") * * *
ERROR MESSAGE STOPS HERE * * *
DataGrid1.SetDataBinding(dataset2, "AutoCAD Files")

End Sub
--
Message posted via DotNetMonster.com
http://www.dotnetmonster.com/Uwe/For...b-net/200508/1
Nov 21 '05 #1
2 1793
Because of what looks like an embedded space in the table name, try:

SELECT * FROM [AutoCAD Files]

HTH,
Tom Dacon
Dacon Software Consulting
"Frustrated Developer via DotNetMonster.com" <fo***@DotNetMonster.com> wrote
in message news:53***********@DotNetMonster.com...
I am trying to establish a connection to an Access 2003 database I have
stored locally on my C:\ drive. However, everytime I try to run my code I
get
the following error message.

An unhandled exception of type 'System.Data.OleDb.OleDbException' occurred
in
system.data.dll

I've looked at several resources and have seen similar code. What am I
overlooking?

Private Sub btnLoad_Click(ByVal sender As System.Object, ByVal e As
System.
EventArgs) Handles btnLoad.Click
Dim dataset2 As New DataSet
dataset2 = New DataSet("dataset2")
Dim ConnectionString As String = "Provider=Microsoft.Jet.OLEDB.4.0;
Data Source = C:\AutoCAD Project\AutoCAD Files.mdb; User ID=Admin"
Dim Connection1 As OleDbConnection = New OleDbConnection
(ConnectionString)
Dim Command1 As OleDbCommand = New OleDbCommand("SELECT * FROM
AutoCAD Files", Connection1)

Connection1.Open()
Command1.Connection = Connection1

Dim daAdapter1 As OleDbDataAdapter = New OleDbDataAdapter

daAdapter1.SelectCommand = Command1
DataGrid1.Visible = True
daAdapter1.Fill(dataset2, "AutoCAD Files") * * *
ERROR MESSAGE STOPS HERE * * *
DataGrid1.SetDataBinding(dataset2, "AutoCAD Files")

End Sub
--
Message posted via DotNetMonster.com
http://www.dotnetmonster.com/Uwe/For...b-net/200508/1

Nov 21 '05 #2
That solved it. I wasn't able to make the connection. Thanks for your
assistance!

Tom Dacon wrote:
Because of what looks like an embedded space in the table name, try:

SELECT * FROM [AutoCAD Files]

HTH,
Tom Dacon
Dacon Software Consulting
I am trying to establish a connection to an Access 2003 database I have
stored locally on my C:\ drive. However, everytime I try to run my code I

[quoted text clipped - 32 lines]

End Sub

--
Message posted via DotNetMonster.com
http://www.dotnetmonster.com/Uwe/For...b-net/200508/1
Nov 21 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Miran Kopmajer | last post by:
I have Oracle JDeveloper10g installed on my computer and connection to Oracle AS works fine but connection to database returns Io exception: The Network Adapter could not establish the connection...
4
by: gaffar | last post by:
Sir, I am developing an application in vb.net and the backend database is ms-access. i have created ms-access databse and tables and assigned primary keys to the tables through the vb.net...
0
by: bmoos1 | last post by:
I have MS Office 2000 and upgraded Access Only to 2003. The problem is I want to use my Access queries for a mail/merge, but I get the error message: "Word could not re-establish DDE...
2
by: Chris Zambas | last post by:
Hi, It is only possible to connect to SQL server Desktop Engine databases and Microsoft Access databases with this version of Visual Studio. What's the workaround to the above problem in...
1
by: gaffar | last post by:
Sir, I am developing an application in vb.net and the backend database is ms-access. i have created ms-access databse and tables and assigned primary keys to the tables through the vb.net...
0
by: bazzer | last post by:
hey, im trying to access a microsoft access database from an ASP.NET web application in visual basic 2003.NET. i get the following error when i try running it: Server Error in...
16
by: gumby | last post by:
I'm having trouble getting HADR to work with the sample databases on two HS20 xSeries blades, Red Hat ES4 up3, DB2 8.2.4, getting the following error. SQL1768N Unable to start HADR. Reason code...
3
by: Ted | last post by:
In WSAT, I get the following error when trying to set up my provider: Could not establish a connection to the database. If you have not yet created the SQL Server database, exit the Web Site...
6
Cintury
by: Cintury | last post by:
Hi all, I've developed a mobile application for windows mobile 5.0 that has been in use for a while (1 year and a couple of months). It was developed in visual studios 2005 with a back-end sql...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.