KABOOM Posted February 4, 2003 Posted February 4, 2003 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 Quote
wyrd Posted February 4, 2003 Posted February 4, 2003 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. :) Quote Gamer extraordinaire. Programmer wannabe.
*Experts* Nerseus Posted February 4, 2003 *Experts* Posted February 4, 2003 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 Quote "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
KABOOM Posted February 4, 2003 Author Posted February 4, 2003 Oh man, that worked like a charm. Thanks for your help. Quote
Chong Posted April 4, 2003 Posted April 4, 2003 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 Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.