problem connecting

nishna

Member
Joined
Jan 17, 2008
Messages
19
Programming Experience
1-3
hi to all.

im connecting vb.net to an access db.
im following online tutorials but im getting error on this line:

conn.ConnectionString = "PROVIDER=Microsoft.Jet.OLEDB.4.0;Data Source = C:\multimodal.mdb"

im not able to figure out what's wrong... since the code looks ok.

The error im getting is:
object reference bot set to an instant of an object

Can any1 plz help me with this...
thnks,
nishna
 
The only thing that can be a null reference in that line is "conn".
 
hi

my code is as follows... i have put only the most important part... n it looks ok... but im getting that error... NullReferenceException was unhandled


Imports System.Data
Imports System.Data.OleDb
Imports ADODB

Public Class frmLogin
Inherits System.Windows.Forms.Form
Private Sub btnLogin_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnLogin.Click
conn.ConnectionString = "PROVIDER=Microsoft.Jet.OLEDB.4.0;Data Source = C:\multimodal.mdb"
conn.Open()
MsgBox("A Connection to the Database is now open")

conn.Close()
End Sub

End Class

any advice would be of great hlp.... i cant figure out what i have missed,,,

thnks,
nishna
 
Ya? "conn" is Nothing, so you have create connection object and assign to "conn" variable. Don't the tutorial teach you how to create a connection?
 
connection problem

i did create with
dim conn as OledbConnection.
but still im getting 'nullReferenceExceptionUnhandled ' as error.

but still im getting this error in the conn variable.

plz advice me.....
thnks, nishna
 
No, you didn't, you simply declared a variable. To create a new object you have to use the "New" keyword with one of the class constructor methods.
 
Back
Top