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

KABOOM

Member
Joined
Jan 26, 2003
Messages
6
Ok, I know I put up a similar question before but im pretty new to this .NET stuff and im not sure if its a problem with my code or if somethings screwy with my installation

First my specs:
Windows 2000 Pro
AMD 2000 processor

I get the below error:
An unhandled exception of type System.Data.OleDb.OleDbException occurred in system.data.dll

What ive tried thus far is install MDAC v2.7 and MS Jet v4.0 SP3 as suggested by the Microsoft site. Still no luck getting VB.NET to connect to my access database.

Im 100% sure the MSJETOLEDB.dll exists in my winnt/system32 directory and most likely isnt corrupt since ive installed it from the packages mentioned above.

Im going to attach my code and snip out a bunch of irrelevant junk. The point where my program complains is highlighted by #######################


Imports System.Data
Imports System.Data.OleDb


Public Class Form1
Inherits System.Windows.Forms.Form

Dim strConnection As String = "Provider=Microsoft.Jet.OLEDB.4.0;" & "_ Data Source=C:\temp\db1.mdb"
Dim mylink As OleDbConnection Connection object


#Region " Windows Form Designer generated code "

Public Sub New()
MyBase.New()

This call is required by the Windows Form Designer.
InitializeComponent()

DATABASE: Make a connection to database
mylink = New OleDbConnection(strConnection)
mylink.Open() ########### CRASH HERE ########

Add any initialization after the InitializeComponent() call

End Sub

// SNIP
End Class
 
Dim strConnection As String = "Provider=Microsoft.Jet.OLEDB.4.0;" & "_ Data Source=C:\temp\db1.mdb"

I think maybe theres a typo here. You have " & " which is concatination but its on one line. In any case, it looks like you had it on two lines (the _ is there) but you put the _ inside the " " just before Data. Perhaps it should be;

Dim strConnection As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\temp\db1.mdb"

Just a rough guess, but it might be worth trying. :) I dont see anything else wrong.

You should wrap your connection up into a try/catch block so you can print out a better error message (hopefully).

Try
db stuff
Catch e As Exception
Console.WriteLine(e.Message())
mylink.Close()
End Try

Something like that, dont have .NET open so not sure on the exact VB syntax for a try/catch. Just start typing, VB is smart enough to correct it. :)
 
It looks like youve got an extra underscore in your connection string.

Try this instead:
Code:
Dim strConnection As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\temp\db1.mdb"

-nerseus
 
data source location

I have the exact error message KABOOM; however, what Im trying to do is not to give the full path to the database file. I have tried Data Source=C:\...\db1.mdb and also Data Source=Data\db1.mdb but I still receive the same error message.

Please help!

Thanks in adavance.

Chong
 
Back
Top