Getting ArcSDE GeoDatabase Domain values

4063
2
Jump to solution
06-04-2013 10:10 AM
SimonLeo
New Contributor III
Hi,

I am trying to read domain table values from ArcSDE GeoDatabase in ArcObjects code. I have two testing GeoDB in Oracle and SQL Server respectively.

1. in ArcCatalog, sde connection->properties->Domains, I can see a list of defined domains and its properties&values. this works fine for both Oracle and SQL Server databases.

2. then in ArcObjects, I tried following code to get a specific domain:
IWorkspaceDomains2 workspaceDomains = (IWorkspaceDomains2)workspace;             IDomain requestedDomain = workspaceDomains.get_DomainByName(domainName);

using Domain names in step 1, only one domain name can actually return a domain object, while all others return null.

3. then I tried following code in order to iterate and get a list of available domain names:
IList<string> domainNameList = new List<string>();             IDomain domain = workspaceDomains.Domains.Next();             while (domain != null)             {                 domainNameList.Add(domain.Name);                 domain = workspaceDomains.Domains.Next();             }

this time, it'll ran into an infinite loop as workspaceDomains.Domains.Next() doesn't actually change domain; the domain points to the same domain name all the time.

I tried this in both databases, no luck.

The data set is from client.

anybody could give me some suggestions on how to look into this issue further? is this more of a data issue? but I can see those domains in ArcCatalog no problem...

thanks in advance!
0 Kudos
1 Solution

Accepted Solutions
ForrestJones
Esri Contributor
Hi Simon,

I checked with someone who uses the gdb api all the time and it looks like IWorkspaceDomains2.Domains pulls all the domains so IWorkspaceDomains2.Domains.Next will always be the first one. He suggested to put the enumeration of domains in another variable and then loop through that.

For example something like:

IEnumDomain allDomains = workspaceDomains.Domains;   IDomain domain = allDomains.Next(); //now loop through allDomains 



You could also pull the domain list using SQL. There is a topic and examples in the doc:

10.1 Help - Browsing geodatabase system tables with SQL

10.1 Help - Example: Finding domain owners using SQL

Hope this helps.

View solution in original post

0 Kudos
2 Replies
ForrestJones
Esri Contributor
Hi Simon,

I checked with someone who uses the gdb api all the time and it looks like IWorkspaceDomains2.Domains pulls all the domains so IWorkspaceDomains2.Domains.Next will always be the first one. He suggested to put the enumeration of domains in another variable and then loop through that.

For example something like:

IEnumDomain allDomains = workspaceDomains.Domains;   IDomain domain = allDomains.Next(); //now loop through allDomains 



You could also pull the domain list using SQL. There is a topic and examples in the doc:

10.1 Help - Browsing geodatabase system tables with SQL

10.1 Help - Example: Finding domain owners using SQL

Hope this helps.
0 Kudos
SimonLeo
New Contributor III
thank you, i think this is the point.
Hi Simon,

I checked with someone who uses the gdb api all the time and it looks like IWorkspaceDomains2.Domains pulls all the domains so IWorkspaceDomains2.Domains.Next will always be the first one. He suggested to put the enumeration of domains in another variable and then loop through that.

For example something like:

IEnumDomain allDomains = workspaceDomains.Domains;  
IDomain domain = allDomains.Next();
//now loop through allDomains 



You could also pull the domain list using SQL. There is a topic and examples in the doc:

10.1 Help - Browsing geodatabase system tables with SQL

10.1 Help - Example: Finding domain owners using SQL

Hope this helps.
0 Kudos