?
Solved

Borland Database Engine using SetConfigParameter to set NET DIR - Object not found Error

Posted on 2007-12-04
3
Medium Priority
?
1,509 Views
Last Modified: 2010-07-27
I'm using SetConfigParameter in Delphi 5 to set the NET DIR but get Object not found error. Here's my code:

SetConfigParameter('\program files\common files\borland shared\bde\;NET DIR','\program files\common files\borland shared\bde\');

I'm using the code for the SetConfigParameter routine from the Borland website

Thanks
0
Comment
Question by:pauljackson5750
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 13

Expert Comment

by:rfwoolf
ID: 20404217
I think the first parameter you're supplying is no good, try adding the drive letter, i.e.
SetConfigParameter('C:\program files\common files\borland shared\bde\;NET DIR','\program files\common files\borland shared\bde\');

personally I add DBTables to my uses clause of the form, then I say

session.netfiledir := 'c:\whatever';
0
 
LVL 13

Accepted Solution

by:
rfwoolf earned 500 total points
ID: 20404255
Okay here's what I found on the borland website and implemented to change the LOCAL SHARE to true.

The first is a general procedure to make changes to the BDE:

The second calls the procedure with the parameter to be set in the BDE config file...
procedure SetConfigParameter2(Param: string; Value: string);
var
  hCfg: hDBICfg;
  Config: SYSConfig;
  Path, Option: string;
  ParamCount, I: word;
  pFields, pFld: pFLDDesc;
  pRecBuf, pRec: pBYTE;
  Found, SelfInitialized: boolean;
  rslt: DBIResult;
 
begin
  {$Ifdef WIN32}
  hCfg := nil;
  pFld := nil;
  pRec := nil;
  Found := False;
  SelfInitialized := False;
  try
    if Pos(';', Param) = 0 then
      raise EDatabaseError.Create('Invalid parameter passed to function.  There must ' +
         'be a semi-colon delimited sting passed');
    Path := Copy(Param, 0, Pos(';', Param) - 1);
    Option := Copy(Param, Pos(';', Param) + 1, Length(Param) - Pos(';', Param));
 
    rslt := DbiGetSysConfig(Config);
    if rslt <> DBIERR_NONE then
    begin
      if rslt = DBIERR_NOTINITIALIZED  then // Engine not initialized error...
      begin
        SelfInitialized := True;
        DbiInit(nil);
        Check(DbiGetSysConfig(Config));
      end
      else
        Check(rslt);
    end;
    (* DbiOpenConfigFile is defined as such:
        function DbiOpenConfigFile (            { Open/Create configuration }
              pszDirPath    : PChar;            { Directory }
              bCreate       : Bool;             { TRUE to create/overwrite }
        var   hCfg          : hDBICfg           { Handle to config }
                           ): DBIResult stdcall; *)
    Check(DbiOpenConfigFile(Config.szIniFile, FALSE, hCfg));
 
    (* DbiCfgGetRecord is defined as such:
        function DbiCfgGetRecord (              { Get a record }
              hCfg          : hDBICfg;          { Config Handle/NULL }
              pszCfgPath    : PChar;            { Path }
        var   iFields       : Word;             { Returned nbr of fields }
              pfldDesc      : pFLDDesc;         { Field descriptors }
              pRec          : Pointer           { Field values }
                           ): DBIResult stdcall; *)
    { Call it without the field and record buffer to get the count... }
    Check(DbiCfgGetRecord(hCfg, PChar(Path), ParamCount, nil, nil));
 
    pFields := AllocMem(ParamCount * sizeof(FLDDesc));
    pFld := pFields;
    pRecBuf := AllocMem(10000);
    pRec := pRecBuf;
 
    { Get the node values... }
    Check(DbiCfgGetRecord(hCfg, PChar(Path), ParamCount, pFields, pRecBuf));
 
    for I := 0 to ParamCount - 1 do
    begin
      if pFields^.szName = Option then
      begin
        StrPCopy(PChar(pRecBuf), Value);
 
        (* DbiCfgModifyRecord is defines as such:
             function DbiCfgModifyRecord (           { Modify a record }
                   hCfg          : hDBICfg;          { Config Handle/NULL }
                   pszCfgPath    : PChar;            { Path }
                   iFields       : Word;             { Nbr of fields }
                   pfldDesc      : pFLDDesc;         { Field descriptors }
                   pRec          : Pointer           { Data values }
                ): DBIResult stdcall; *)
        Check(DbiCfgModifyRecord(hCfg,  PChar(Path), ParamCount, pFld, pRec));
 
        Found := True;
     end;
      Inc(pFields);
      Inc(pRecBuf, 128);
    end;
    if Found = False then
      raise EDatabaseError.Create(Param + ' entry was not found in configuration file');
 
  finally
    if pFld <> nil then
      FreeMem(pFld);
    if pRec <> nil then
      FreeMem(pRec);
    if hCfg <> nil then
 
    (* DbiCloseConfigFile is defined as such:
           function DbiCloseConfigFile (           { Close the config file }
           var   hCfg          : hDBICfg;          { Handle }
                 bSave         : Bool;             { To save the changes }
                 bDefault      : Bool;             { To make this file the default }
                 bSaveAs16     : Bool              { To save as a 16-bit config file }
              ): DBIResult stdcall; *)
      { Close and save the config file... }
    Check(DbiCloseConfigFile(hCfg, TRUE, TRUE, FALSE));
    if SelfInitialized = True then
      DbiExit;
  end;
  {$Else}
     raise EDatabaseError.Create('Non supported function in 16 bit');
  {$EndIf}
end;
 
 
 
 
 
 
 
===============================================================
 
 
 
 
 
  //Set LOCAL SHARE TO TRUE
SetConfigParameter2('\SYSTEM\INIT\;LOCAL SHARE', 'TRUE');

Open in new window

0
 

Author Closing Comment

by:pauljackson5750
ID: 31412922
Used the session.netfiledir := getcurrentdir and it seems to work.

Many thanks
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…
Suggested Courses

801 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question