Load layer from ms access database

Hi all,
I have a personal ms access database file that is created using ArcMap.
I am trying to load features from it using AxMap.AddLayerFromDatabase() but the code always fails to open it.
See Sample:

        private void loadFromDb(string layer)
        {
        try
        {                
            string layerName = "index2";
            int handler = axMap1.AddLayerFromDatabase(connString, layerName, true);
            if(handler == -1)
            {
                MessageBox.Show("Failed to open layer " + layerName);
            }
            else
            {
                 //...
            }
        }
        catch(Exception ex)
        {
            MessageBox.Show(ex.ToString());
        }
    }

When I use non-spatial ms access database for login for example, it works without problem. But I copied all my tables from it to a ArcMap personal geodatabase it does not open.
Help please.

Hello @alrajhi20

Please share your connection string. It’s unclear whether you are trying to connect to the MS Access database or the ESRI Personal Geodatabase created from the Access database; and they would use different drivers (included in the connection string, see the documentation here).

We use GDAL for database access (anything other than Shapefiles) and I’m not sure if the ESRI driver is built-in by default. Check out the FileGDB driver here.

Regards,
Jerry.

Dear Mr. Jerry, thank you for you replay.
Connection String: “Provider=Microsoft.Jet.OLEDB.4.0; Data Source=D:\Projects\root\data\gisdb.mdb; Jet OLEDB:Database Password=123;”
Database gisdb.mdb is ESRI personal geodatabase which is .MDB format.
Hope I made myself clear.

Hello again.

I’m sorry I can’t be more help. I’m not familiar with this method of data access, but it looks like it can be done. Here is the GDAL documentation for the Personal GeoDatabase, in case it helps. Otherwise, perhaps someone else has had some experience with this and can provide some advice.

Regards,
Jerry.

Thank you Mr. Jerry, I will definitely look to it.

Hi all, unfortunately I could not manage to have the code running for some reasons I may not be aware of. Waiting for any help