Accessing data in a database

Options
LaurentianUniversity
edited February 2023 in GeoStudio
I am building a C# dll, and currently I have got myself to the point where I can load it into Oasis Montaj, and do various little things, however I am having trouble figuring out the best method to get at the data inside of a database. Essentially, I want to access the loaded database to get the x, y, and measurement values from a survey, and store them in some double-type arrays to do some processing on them. It looks like there are a couple of methods of doing this, such as looping through the lines and using CDB.rGetChanReal to get the channel values, but this method specifically states that it is slow. Is there some other method of mass copying each channel to an array?

Thank you,

Tomas Naprstek
Tagged:

Comments

  • JosephCaluag1
    Options
    Hi Tomas,

    You can use the GetChanVV function to retrieve the values of a channel on a specific line and store them inside a VV.

    For example:
    Data.GetChanVV(Line, XCh, hXVV);

    You can see a sample of this in RangeDB.cs, which can be found in the gxnet\src\DBUtilities folder.

    I hope this helps.

    Regards,
    Joseph
  • LaurentianUniversity
    edited May 2016
    Options
    I understand this a bit more now. Thank you for the feedback!

    Unfortunately I've run into another problem. I'm primarily following the chanadd example code, however I am running into a problem putting the data back into the database. Following the chanadd code, it always stops at this line:

    hDB.PutChanVV(iLine, iChan, hVV);

    The only code I have added to the chanadd code is from the SimplGX template so as to build a menu for this that I can use to run the dll. I changed/added:

    namespace chanaddTN
    {
    public partial class chanaddTN : BaseForm
    {
    public chanaddTN(IntPtr pGeo)
    : base(pGeo)
    {
    TranslateControls();
    }

    I also changed:

    static void Main(string[] args)

    into:

    public void run()

    and just manually entered the string for my specific case:

    string[] args = new string[3];
    args[0] = "BaseModel1-250mInterval-1nTNoise";
    args[1] = "data";
    args[2] = "5";

    Would you be able to shed some light on what I am doing wrong here? It runs fine in Oasis from the menu I added up until the PutChanVV line.

    EDIT: Just for clarity, everything up to that point seems to be running fine, as I have checked the iS variable (iS = hVV.iLength();) and it is correct in how long the database channel is, and other such checks.
  • JosephCaluag1
    Options
    Hi Tomas,

    Your additions to the sample chanadd should not cause any issues. I will send you a message so I can review your setup and full source code.

    Joseph
This discussion has been closed.