Android smartphone

2010-01-25

detect, which version of ADO is installed ?

Author: Simon Carter

With different versions of MDAC available it is sometimes

useful to know that your application won't fail because a user
hasn't got the latest version installed.
The following function returns the ADO version installed,
you need to place ComObj in the uses clause to use this function. }

function GetADOVersion: Double;
var
ADO: Variant;
begin
try
ADO := CreateOLEObject('adodb.connection');
Result := StrToFloat(ADO.Version);
ADO := Null;
except
Result := 0.0;
end;
end;

// To use this function try something like:

procedure TForm1.Button1Click(Sender: TObject);
const
ADOVersionNeeded = 2.5;
begin
if
GetADOVersion <>then
ShowMessage('Need to install MDAC version 2.7')
else
ShowMessage(Format('ADO Version %n, is OK', [GetADOVersion]));
end;

make an ADODB Connection using OLE-Automation ?

Author: Daniel Henrique Monteiro de Carvalho (Brasil)

{...}

uses
ComObj;
{...}

function OpenConnection(ConnectionString: AnsiString): integer;
var
ADODBConnection: OleVariant;
begin
ADODBConnection := CreateOleObject('ADODB.Connection');
ADODBConnection.CursorLocation := 3; // User client
ADODBConnection.ConnectionString := ConnectionString;
Result := 0;
try
ADODBConnection.Open;
except
Result := -1;
end;
end;

function DataBaseConnection_Test(bMessage: boolean): AnsiString;
var
asTimeout,
asUserName,
asPassword,
asDataSource,
ConnectionString: AnsiString;
iReturn: Integer;
OldCursor: TCursor;
begin
OldCursor := Screen.Cursor;
Screen.Cursor := crHourGlass;
asTimeout := '150';
asUserName := 'NT_Server';
asPassword := 'SA';
asDataSource := 'SQL Server - My DataBase';

ConnectionString := 'Data Source = ' + asDataSource +
'User ID = ' + asUserName +
'Password = ' + asPassword +
'Mode = Read|Write;Connect Timeout = ' + asTimeout;
try
iReturn := OpenConnection(ConnectionString);

if (bMessage) then
begin
if
(iReturn = 0) then
Application.MessageBox('Connection OK!', 'Information', MB_OK)
else if (iReturn = -1) then
Application.MessageBox('Connection Error!', 'Error', MB_ICONERROR

+ MB_OK);
end;
if (iReturn = 0) then

Result := ConnectionString
else if (iReturn = -1) then
Result := '';
finally
Screen.Cursor := OldCursor;
end;
end;


procedure TForm1.Button1Click(Sender: TObject);
begin
DataBaseConnection_Test(true);
end;

check, if the Borland Database Engine (BDE) is installed ?

Author: tom

Uses
Bde;

function BDEInstalled : boolean;
begin
result := (dbiInit(nil) = 0)
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
if
BDEInstalled then
ShowMessage('BDE is installed.')
else
ShowMessage('BDE is not installed.')
end;


Get the table version ?

Author: SwissDelphiCenter.ch

Homepage: http://www.swissdelphicenter.ch

function GetTableVersion(table: TTable): LongInt;
var
hCursor : hDBICur;
DT : TBLFullDesc;
begin
Check(DbiOpenTableList(table.DBHandle, True, False,
PChar(Table.TableName), hCursor));
Check(DbiGetNextRecord(hCursor, dbiNOLOCK, @DT, nil));
Result := DT.tblExt.iRestrVersion;
Check(DbiCloseCursor(hCursor));
end;