How to add a reference to an FGDB in the database folder of the project?

374
3
Jump to solution
05-31-2021 07:49 AM
MarioLandry2
New Contributor

Hello dear community,

I've created a small program that does create a series of projects and that also creates individual FGDBs inside those projects.

For example, I have a project named f24010 and within that project there is a FGDB named Extract_f24010.

I can see the FGDB in the folder "Folders", but I can't see the same database in the folder "Databases"

 

MarioLandry2_0-1622472053410.png

Using ArcGIS Pro SDK, how can I add a reference to the FGDB in the "Databases" folder?

Mario

0 Kudos
1 Solution

Accepted Solutions
ThanHtetAung_EsriAu
Esri Regular Contributor

Hi @MarioLandry2 ,

Try that sample code.

Your method need to be async, fgdbpath should be string variable and store your file geodatabase path.

 

ProgressorSource ps = new ProgressorSource("Adding fgdb connections");
await QueuedTask.Run(async () =>
                            {
                                ps.Message = $"Adding fgdb path....";
                                IProjectItem tmpItem = ItemFactory.Instance.Create(fgdbpath) as IProjectItem;
                               
                                bool isAdded = Project.Current.AddItem(tmpItem);
                                
                            }, ps.Progressor);

 

 

View solution in original post

0 Kudos
3 Replies
MarioLandry2
New Contributor

I've realized that I could use the id command "esri_projectitemAddToProjectButton" but it does not work, mainly because I guess I don't know how to call a command ids with a parameter, in that case the FGDB file name.

0 Kudos
ThanHtetAung_EsriAu
Esri Regular Contributor

Hi @MarioLandry2 ,

Try that sample code.

Your method need to be async, fgdbpath should be string variable and store your file geodatabase path.

 

ProgressorSource ps = new ProgressorSource("Adding fgdb connections");
await QueuedTask.Run(async () =>
                            {
                                ps.Message = $"Adding fgdb path....";
                                IProjectItem tmpItem = ItemFactory.Instance.Create(fgdbpath) as IProjectItem;
                               
                                bool isAdded = Project.Current.AddItem(tmpItem);
                                
                            }, ps.Progressor);

 

 

0 Kudos
MarioLandry2
New Contributor

Thanks a lot Than!

0 Kudos