Read/write Meta information in a gdb using gxnet

JohnPaine Posts: 14 Calcite Rank Badge
edited February 2023 in GeoStudio

I'm having difficulty in creating and writing information in the Metadata for a gdb. I followed the process used in the FileToandFromGDB.cs, but it doesn't work for me. The relevant (elided) code section is this:

hMETA = CMETA.Create();

var mcData = hMETA.ResolveUMN("CLASS:/Geosoft/Data");

var maSliceWidth = hMETA.ResolveUMN("ATTRIB:/Geosoft/Data/SliceWidth");

// attribute doesn't exist, so create it

maSliceWidth = hMETA.CreateAttrib("ATTRIB:/Geosoft/Data/Time Slice Width", mcData, META_CORE_TYPEConstant.I4);
hMETA.SetAttribInt(mcData, maSliceWidth, iTimeSliceNum);

// save the modified meta data


return iTimeSliceNum;


// the attribute exists, so get the value

int iSliceWidth = 0;
hMETA.GetAttribInt(mcData, maSliceWidth, ref iSliceWidth);
return iSliceWidth;

Each of the steps seems to work fine and return valid responses. But if I create a gdb, add the SliceWidth attribute as above, then query the SliceWidth attribute again, it doesn't find it and repeats the creation code.

Many thanks
John Paine


  • JosephCaluag1
    Hi John,

    You can create the class and then the attribute like so:
    var mcData = hMETA.CreateClass("CLASS:/Geosoft/Data", GeoEngine.Core.GXNet.Constant.META_CORE_CLASS_Predefined);
    var maSliceWidth = hMETA.CreateAttrib("ATTRIB:/Geosoft/Data/SliceWidth", GeoEngine.Core.GXNet.Constant.META_CORE_CLASS_Predefined, META_CORE_TYPEConstant.I4);

    Then you should be able to see if it has a value:
    if (hMETA.iHasValue(mcData, maSliceWidth) != 1)

    I would also recommend to look at the CREG class to store and retrieve values.


  • JohnPaine
    Hi Joseph,

    Great, that fixed the problem and I can now read and write metadata values in the database.

    I checked the cs files gxnet/src folder and found the method I used in the FileToandFromGDB sample and that was why I tried to do it that way. I just checked and there don't appear to be any samples which use the method you supplied.

    Also, I had a look at the CREG class and it says:

    The REG class is used for storing and retrieving named variables. Many classes contain REG objects for storing information particular to the class. The META class supersedes the REG class and is gradually replacing the use of the REG class in newer applications.

    As I want these values to be parameters specific each database, I would expect that the Metadata is the better approach for storing the information.

    Best regards

This discussion has been closed.