Quantcast
Channel: VBForums - Visual Basic .NET
Viewing all articles
Browse latest Browse all 27240

Cannot Open Access in VB 2008

$
0
0
Dear all,

I have been trying to open my Access Database without success. In the beginning there are no data sources, so I go through the routine of adding a new data source, and receive the following reports; the last one being the error that stops all further action.

Attachment 96863Attachment 96865Attachment 96867


Below is my code. As you will see I used 2 examples of ‘Provider’, and both get the same responses.

Code:

Imports System.Data.OleDb
Public Class frmMovieDataBase

    Dim ConnectionString As String
    Dim conn As OleDbConnection
    Dim AccessDataAdapter As New OleDbDataAdapter()
    Private Sub btnEnter_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnEnter.Click

        conn = New OleDbConnection(ConnectionString)
        conn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=H:\Movies\Movies.mdb;"
        'conn.ConnectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=H:\Movies\Movies.accdb;"

        Try
            conn.Open()
            MsgBox("Connection Open ! ")
            conn.Close()
        Catch ex As Exception
            MsgBox("Can not open connection ! ")
        End Try

    End Sub

Please advise what I am doing wrong.

Regards,

john
Attached Images
     

Viewing all articles
Browse latest Browse all 27240

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>