Jump to content
Xtreme .Net Talk

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


Recommended Posts

Posted

Ok, I know I put up a similar question before but i'm pretty new to this .NET stuff and i'm not sure if it's 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 i've 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.

 

I'm 100% sure the MSJETOLEDB.dll exists in my winnt/system32 directory and most likely isn't corrupt since i've installed it from the packages mentioned above.

 

I'm 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

Posted

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

 

I think maybe there's a typo here. You have " & " which is concatination but it's 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 don't 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, don't 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. :)

Gamer extraordinaire. Programmer wannabe.
  • *Experts*
Posted

It looks like you've got an extra underscore in your connection string.

 

Try this instead:

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

 

-nerseus

"I want to stand as close to the edge as I can without going over. Out on the edge you see all the kinds of things you can't see from the center." - Kurt Vonnegut
  • 2 months later...
Posted

data source location

 

I have the exact error message KABOOM; however, what I'm 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

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...