I'm trying to a open a connection to a local database and no matter what I try it just won't work (I'm pretty new to SQL Server and VB for that matter) I tried using 'sqlconnection' with different connection strings but none of them worked or gave me any useful error messages so I tried using 'OleDBConnection' instead, this hasn't worked either and it gives me this error instead:
"A first chance exception of type 'System.NullReferenceException' occurred in MyProgram.exe"
Here is the code I am currently trying:
Private Sub MemDetailsSearch_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
ConnectionString = ("Provider = Microsoft.Jet.OLEDB.4.0;" & "Data Source = Database.sdf")
DataConnect = New OleDbConnection(ConnectionString)
Try
DataAdapter.SelectCommand.Connection = DataConnect
DataConnect.Open()
MsgBox("Connection to database successful!")
Catch ex As Exception
MsgBox("Connection to database failed!")
End Try
End Sub
End Class
It's probably something simple as I am quite new to this and I'd appreciate if someone could point out what I'm doing wrong, thanks.