Hi all,

I am new to the VB.net. I am trying to connect db with very simple code but giving following error:

An unhandled exception of type 'System.NullReferenceException' occurred in TestConn.exe

Additional information: Object reference not set to an instance of an object.

See the CODE below:

Imports System.Data
Imports System.Data.OleDb
Imports System.Data.SqlClient

Public Class Form1
Inherits System.Windows.Forms.Form
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim con As OleDb.OleDbConnection
con.ConnectionString = "PROVIDER=Microsoft.Jet.OLEDB.4.0;Data Source = C:\Documents and Settings\img\My Documents\Visual Studio Projects\TestConn\AddressBook.mdb"
con.Open()
MsgBox("A Connection to the Database is now open")
con.Close()
MsgBox("The Connection to the Database is now Closed")
End Sub
End Class

Pls help me to solve the prob.

Thanks,
Gitesh