I get an error message when connecting to an access database

Moshe Singer
Moshe Singer used Ask the Experts™
on
In vb.net, 2015- when I connect to an access database, with the following code:

Dim StnStr() As String
        StnStr = "Data Source=servername; Initial Catalog=databasename; User ID=userid; Password=password"
        StnStr = "Provider=MSDataShape;Data Provider=Microsoft.Jet.OLEDB.4.0;"
        StnStr = StnStr & "Jet OLEDB:System database=" & My.Application.Info.DirectoryPath & "\System.mdw;"
        StnStr = StnStr & "Password=PW;User ID=USERNAME;"
        StnStr = StnStr & "Data Source=" & My.Application.Info.DirectoryPath & "\data.mdb;"
        StnStr = StnStr & "Persist Security Info=False"

 Dim CON As New OleDb.OleDbConnection(StnStr)
       CON.Open()


I receive the following error message in the output window:

The program '[3660] UpdateCrgs.vshost.exe' has exited with code -1073741819 (0xc0000005) 'Access violation'.
What can this mean?
In other projects it seems fine, why in this project am I getting this message?
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Most Valuable Expert 2014

Commented:
I'm a thinkin' this is a little hatched

StnStr = "Provider=MSDataShape;Data Provider=Microsoft.Jet.OLEDB.4.0;"
https://msdn.microsoft.com/en-us/library/ms254500(v=vs.110).aspx

Are you sure that the MSDataShape provider is in use with an .mdb data source?
And are you sure you want to carry on with that, as it seems that MS is deprecating it?
https://msdn.microsoft.com/en-us/library/ms676105(v=vs.85).aspx
Moshe Singerdeveloper

Author

Commented:
I have the same situation if I use
Provider=Microsoft.Jet.OLEDB.4.0;
Most Valuable Expert 2014
Commented:
Perhaps it isn't MS Access violation!

Perhaps it is 'access violation' as in you don't have appropriate NTFS security on the file
Or something else that is causing a memory access violation.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial