[GIS] Connecting to non geodatabase MS Access database using ArcObjects

arcobjectsms accessvb.net

I am trying to connect to an MS Access database from a program I have written in VB.Net with ArcObjects 10.0. My MS Access database is not a personal geodatabase so apparently I have to connect to Access using an OLEDBWorkspaceFactory.

Dim propset As IPropertySet2 = New PropertySet
propset.SetProperty("CONNECTIONSTRING", "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & txtbox1.Text & ";User Id=admin;Password=;")

Dim oleWorkspace As IWorkspaceFactory2 = New OLEDBWorkspaceFactory
Dim m_workspace As IWorkspace2

If oleWorkspace IsNot Nothing Then m_workspace = oleWorkspace.Open(propset, 0)

The above code works except for one minor detail. When I call oleWorkspace.Open(propset, 0) I get the ArcGIS Database Connection dialogue asking what driver to use and for connection information (which I have already provided in my propertyset).

Is there a way to avoid this dialogue?

Best Answer

You should be able to use the AccessWorkspaceFactory co-class even though it's not a personal geodatabase. You could also use ADO.NET. I am not sure why your code isn't working but I do know that working with property sets is an exercise in frustration.