# Load layer from ms access database

**URL:** <https://mapwindow.discourse.group/t/load-layer-from-ms-access-database/997>\
**Category:** MapWinGIS\
**Created:** [May 18, 2021, 4:16am UTC](https://mapwindow.discourse.group/t/load-layer-from-ms-access-database/997 "2021-05-18T04:16:36Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![alrajhi20](https://avatars.discourse-cdn.com/v4/letter/a/ee7513/32.png) [@alrajhi20](https://mapwindow.discourse.group/u/alrajhi20)\
**Post date:** [May 18, 2021, 4:16am UTC](https://mapwindow.discourse.group/t/load-layer-from-ms-access-database/997/1 "2021-05-18T04:16:36Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![jerryfaust](https://yyz2.discourse-cdn.com/free1/user_avatar/mapwindow.discourse.group/jerryfaust/32/378_2.png) [@jerryfaust](https://mapwindow.discourse.group/u/jerryfaust)\
**Post date:** [May 19, 2021, 4:04am UTC](https://mapwindow.discourse.group/t/load-layer-from-ms-access-database/997/2 "2021-05-19T04:04:31Z")

</div>

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](https://www.mapwindow.org/documentation/mapwingis4.9/group __map__ layer__management.html#ga3672fae9774e0bbb917ab23e13855ebe)).

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](https://gdal.org/drivers/vector/filegdb.html#vector-filegdb).

Regards,  
Jerry.

---

<div class="post-metadata">

**Author:** ![alrajhi20](https://avatars.discourse-cdn.com/v4/letter/a/ee7513/32.png) [@alrajhi20](https://mapwindow.discourse.group/u/alrajhi20)\
**Post date:** [May 20, 2021, 3:11am UTC](https://mapwindow.discourse.group/t/load-layer-from-ms-access-database/997/3 "2021-05-20T03:11:59Z")

</div>

> [@alrajhi20](#):
>
> `AddLayerFromDatabase`

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.

---

<div class="post-metadata">

**Author:** ![jerryfaust](https://yyz2.discourse-cdn.com/free1/user_avatar/mapwindow.discourse.group/jerryfaust/32/378_2.png) [@jerryfaust](https://mapwindow.discourse.group/u/jerryfaust)\
**Post date:** [May 20, 2021, 4:35am UTC](https://mapwindow.discourse.group/t/load-layer-from-ms-access-database/997/4 "2021-05-20T04:35:31Z")

</div>

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](https://gdal.org/drivers/vector/pgeo.html?highlight=esri), in case it helps. Otherwise, perhaps someone else has had some experience with this and can provide some advice.

Regards,  
Jerry.

---

<div class="post-metadata">

**Author:** ![alrajhi20](https://avatars.discourse-cdn.com/v4/letter/a/ee7513/32.png) [@alrajhi20](https://mapwindow.discourse.group/u/alrajhi20)\
**Post date:** [May 20, 2021, 5:35am UTC](https://mapwindow.discourse.group/t/load-layer-from-ms-access-database/997/5 "2021-05-20T05:35:12Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![alrajhi20](https://avatars.discourse-cdn.com/v4/letter/a/ee7513/32.png) [@alrajhi20](https://mapwindow.discourse.group/u/alrajhi20)\
**Post date:** [June 24, 2021, 5:15am UTC](https://mapwindow.discourse.group/t/load-layer-from-ms-access-database/997/6 "2021-06-24T05:15:35Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![pmeems](https://yyz2.discourse-cdn.com/free1/user_avatar/mapwindow.discourse.group/pmeems/32/9_2.png) [@pmeems](https://mapwindow.discourse.group/u/pmeems)\
**Post date:** [January 5, 2022, 1:45pm UTC](https://mapwindow.discourse.group/t/load-layer-from-ms-access-database/997/7 "2022-01-05T13:45:39Z")

</div>


