If you are using a local database (i.e. dBase or Paradox) then you probably ale have the BDE setting “LOCAL SHARE” set to false, which does not save changes to databases after they are modified immediately. The changes are kept in memory and saved later. In other words – cached.
This usually helps speed up database modifications because you don’t have a physical write after each and every change.
The problem may occur when your application (or Microsoft Windows itself
) crash. That’s when you know that your changes are gone forever. To work around this just save the database after every posting. Just add code to your TTable’s AfterPost property.
uses
BDE;
...
procedure TForm1.Table1AfterPost(DataSet: TDataSet);
begin
DbiSaveChanges(Table1.Handle);
end;
Categories: Databases Tags: borland, code, corruption, data, database, db, Delphi, freeware, loss, open source, prevent, prevetion, save, source, source code, tip, trick
For many reasons you may need the installed BDE (Borland Database Engine) version. One of them (the main one probably) is that BDE versions are not always compatible with each other. Therefore you may want to use different code/components at runtime.
Use the code below to determine what version of BDE is installed on the system. The first snippet does not use the registry while the second one does.
1. Without quering the Windows system registry:
var
BDEVersion: SYSVersion;
...
DbiGetSysVersion(BDEVersion);
// BDEVersion.iVersion - BDE version
...
2. With the use of the Windows system registry:
uses
BDE, Registry, Windows;
...
function GetBDEVersion: string;
var
hDll: hWnd;
pFunc: Pointer;
sIdAPI: string;
SysVer: SYSVersion;
SysVerProc: TSYSVerProc;
begin
Result := '';
with TRegistry.Create do
try
RootKey := HKEY_CLASSES_ROOT;
if OpenKey('CLSID{FB99D710-18B9-11D0-A4CF-00A024C91936}InProcServer32',
False) then begin
sIdAPI := ReadString('');
CloseKey;
end;
finally
Free;
end;
hDll := LoadLibrary(PChar(idapi));
if hDll <> 0 then
try
pFunc := GetProcAddress(hDll, 'DbiGetSysVersion');
if pFunc <> nil then begin
SysVerProc := pFunc;
SysVerProc(SysVer);
Result := IntToStr(SysVer.iVersion);
Insert('.', Result, 2);
end;
finally
FreeLibrary(hDll);
end;
end;
Categories: Databases Tags: bde, borland, borland database engine, code, database, Delphi, engine, faq, free, get, retrieve, source code, tip, trick, version