# Load layer from GDB to mapControl

**URL:** <https://mapwindow.discourse.group/t/load-layer-from-gdb-to-mapcontrol/1173>\
**Category:** Uncategorized\
**Created:** [December 17, 2021, 8:05pm UTC](https://mapwindow.discourse.group/t/load-layer-from-gdb-to-mapcontrol/1173 "2021-12-17T20:05:55Z")\
**Posts on this page:** 3\
**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:** [December 17, 2021, 8:05pm UTC](https://mapwindow.discourse.group/t/load-layer-from-gdb-to-mapcontrol/1173/1 "2021-12-17T20:05:55Z")

</div>

Hi all, I could add layer as shapefile to map control. What I could not achieve is loading data from ESRI Geodatabase to map control  
Here is my code:

```auto
try
            {
                var ogr = new OgrDatasource();
                string source = @"url\data.gdb";
                if (!ogr.Open(source))
                {
                    MessageBox.Show("Failed to open data source. Err: " + ogr.GdalLastErrorMsg);
                }
                else
                {
                    //My problem is here. 
                    // What is the proper code to add one of the layers from the gdb to map control
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }

```

After successfully connecting to gdb, what is the right function to add one of the layers in gdb to map control: axMap

---

<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:39pm UTC](https://mapwindow.discourse.group/t/load-layer-from-gdb-to-mapcontrol/1173/2 "2022-01-05T13:39:31Z")

</div>

I see you asked the same question at [Add Layer from Geodatabase not working](https://mapwindow.discourse.group/t/add-layer-from-geodatabase-not-working/1193)  
Since that one has some replies I’ll close this one.

---

<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:39pm UTC](https://mapwindow.discourse.group/t/load-layer-from-gdb-to-mapcontrol/1173/3 "2022-01-05T13:39:37Z")

</div>

Closed on January 5, 2022, 1:39pm UTC


