Board index » delphi » change the language driver of a paradox table

change the language driver of a paradox table

Hi,

my question is:

How can I change the language driver of a paradox table at runtime?
I know the function "DbiDoRestructure()" and the
datastruct "CRTblDesc",
but I dont know how to use...
Can not understand the  CRTblDesc-object "iOptParams"
---
UINT16 iOptParams Optional; specifies the number of optional
                        parameters (for example, language driver
information).
---

Who can help?
Thanks in advance.

Greetings from Frankfurt

Ron

 

Re:change the language driver of a paradox table


Quote
> How can I change the language driver of a paradox table at runtime?
> I know the function "DbiDoRestructure()" and the
> datastruct "CRTblDesc",
> but I dont know how to use...
> Can not understand the  CRTblDesc-object "iOptParams"

The foolowing code should to that:

----->Begin source<-----
procedure SetLanguage(Tbl: TTable; Lang: DbiName);
var
  pOptDesc: pFLDDesc;
  pOptData: pBYTE;
  hDb: hDbiDb;
  TblDesc: CRTblDesc;
  Dir: String;
begin
  pOptDesc := AllocMem(sizeof(FLDDesc));
  pOptData := AllocMem(20);
  SetLength(Dir, dbiMaxNameLen + 1);
  Tbl.Active := True;
  Check(DbiGetDirectory(Tbl.DBHandle, False, PChar(Dir)));
  SetLength(Dir, StrLen(PChar(Dir)));
  try
    FillChar(TblDesc, sizeof(CRTblDesc), #0);
    Tbl.DisableControls;
    Tbl.Close;
    Check(DbiOpenDatabase(nil, nil, dbiReadWrite, dbiOpenExcl, nil, 0, nil,
nil, hDb));
    Check(DbiSetDirectory(hDb, PChar(Dir)));
    pOptDesc.iOffset := 0;
    pOptDesc.iLen := Length(Lang) + 1;
    StrPCopy(pOptDesc.szName, 'LANGDRIVER');
    StrPCopy(PChar(pOptData), Lang);
    TblDesc.iOptParams := 1;
    TblDesc.pfldOptParams := pOptDesc;
    TblDesc.pOptData := pOptData;
    StrPCopy(TblDesc.szTblName, Tbl.TableName);
    StrCopy(TblDesc.szTblType, szParadox);
    Check(DbiDoRestructure(hDb, 1, @TblDesc, nil, nil, nil, False));
  finally
    Check(DbiCloseDatabase(hDb));
    FreeMem(pOptDesc, sizeof(FLDDesc));
    FreeMem(pOptData, 20);
    Tbl.EnableControls;
  end;
end;
----->End source<-----

Other Threads