Mega Code Archive

 
Categories / Delphi / ADO Database
 

Bde fonksiyonları 6

Deactivate and drop a filter on the specified table. This example uses the following input: fDbiDropFilter(Table1, hFilter); The procedure is defined as: procedure fDbiDropFilter(Table: TTable; var hFilter: hDBIFilter); var Props: CURProps; begin Check(DbiGetCursorProps(Table.Handle, Props)); // Check to see if there are any active filters on the cursor if (Props.iFilters = 0) then raise EDatabaseError.Create('There are no active filters on the specified cursor'); if( hFilter <> nil) then begin // Deactivate and drop filter Check(DbiDeactivateFilter(Table.Handle, hFilter)); Check(DbiDropFilter(Table.Handle, hFilter)); end else raise EDatabaseError.Create('Filter handle is invalid or already dropped'); end; //********************************************************************************** Drop a password. Delphi users should use TSession.RemovePassword method rather than directly calling dbiDropPassword. The method TSession.RemovePassword is defined as: procedure RemovePassword(const Password: string); The following code removes a password called "Hip Hop" from TSession Session: Session.RemovePassword('Hip Hop'); //********************************************************************************** End the master/detail link and close the associated cursors. This example uses the following input: fDbiEndLinkMode(hMas, hDet); The procedure is defined as: procedure fDbiEndLinkMode(var hMasCur, hDetCur: hDBICur); begin Check(DbiUnlinkDetail(hDetCur)); Check(DbiEndLinkMode(hMasCur)); Check(DbiEndLinkMode(hDetCur)); Check(DbiCloseCursor(hMasCur)); Check(DbiCloseCursor(hDetCur)); end; //************************************************************************************ End the specified transaction: Delphi users should use the TDataBase.Commit,TDataBase.RollBack methods rather than directly calling DbiEndTran. These methods are defined as: procedure TDataBase.Commit; procedure TDataBase.RollBack; The following code ends a transaction on a TDataBase object called DataBase1 and rolls back changes to the pre-transaction state: { cancels all modifications made to DataBase1 since last call to StartTransaction } DataBase1.RollBack The following code ends a transaction on a TDataBase object called DataBase1 and commits changes to the table: { commits all modifications made to DataBase1 since last call to StartTransaction. } DataBase1.Commit; end; End the master/detail link and close the associated cursors. This example uses the following input: fDbiEndLinkMode(hMas, hDet); The procedure is defined as: procedure fDbiEndLinkMode(var hMasCur, hDetCur: hDBICur); begin Check(DbiUnlinkDetail(hDetCur)); Check(DbiEndLinkMode(hMasCur)); Check(DbiEndLinkMode(hDetCur)); Check(DbiCloseCursor(hMasCur)); Check(DbiCloseCursor(hDetCur)); end; //************************************************************************************* Exit BDE You should not call dbiExit in a Delphi application if you have any of the "Data Access" or "Data Controls" VCL components in your project. Those components will automatically call dbiInit and dbiExit. If you are not using VCL database controls and have called dbiInit yourself, then the following code properly deinitializes the engine: Check(DbiExit);. //************************************************************************************* Extract the key value for the current record. This example assumes the field is of type character and uses the following input: fDbiExtractKey(Table1.Handle, KeyValue); The procedure is defined as: procedure fDbiExtractKey(hTmpCur: hDBICur; var KeyBuff: string); var P: PChar; Props: CurProps; begin Check(DbiGetCursorProps(hTmpCur,Props)); GetMem(P, Props.IkeySize); Check(DbiExtractKey(hTmpCur, nil, P)); KeyBuff:= StrPas(P); FreeMem(p, Props.IkeySize); end; //************************************************************************************ Update the record buffer with current record information. This example uses the following input: fDbiForceRecordReread(hCur, pRecBuf); The procedure is defined as: procedure fDbiForceRecordReread(hTmpCur : hDBICur, pTmpRecBuf : pBYTE) begin Check(DbiForceRecordReread(hTmpCur, pTmpRecBuf)); end; //*********************************************************************************** Refresh all buffers associated with TTable component T: procedure ForceReread(T: TTable); begin Check(DbiForceReread(T.Handle)); end; //************************************************************************************ Return the fully qualified table name and path. This example uses the following input: FullName:=fDbiFormFullName(Table1); The function is defined as: function fDbiFormFullName(Tbl: TTable): string; var Props: CurProps; begin Check(DbiGetCursorProps(Tbl.Handle,Props)); SetLength(Result, DBIMAXPATHLEN); Check(DbiFormFullName(Tbl.DBHandle, PChar(Tbl.TableName), Props.szTableType, PChar(Result))); end; //************************************************************************************* Display the specified field's memo heading. The field specified in BlobIndex must be a valid memo blob and the BlobBuffer must be allocated. Used only with Paradox memo fields. This example uses the following input: fDbiGetBlobHeading(BIOLIFE_TABLE, BIOLIFE_TABLE.FieldByName('Notes').Index, BlobBuffer); The procedure is defined as: procedure fDbiGetBlobHeading(InDataSet: TDataSet; BlobIndex: Word; var P: PChar); var NumRead: longint; begin Inc(BlobIndex); // Parameter iField of DbiOpenBlob requires an ordinal field number InDataSet.UpdateCursorPos; Check(DbiOpenBlob(InDataSet.Handle, InDataSet.ActiveBuffer, BlobIndex, dbiReadOnly)); Check(DbiGetBlobSize(InDataSet.Handle, InDataSet.ActiveBuffer, BlobIndex, NumRead)); Check(DbiGetBlobHeading(InDataSet.Handle, BlobIndex, InDataSet.ActiveBuffer, P)); Check(DbiFreeBlob(InDataSet.Handle, InDataSet.ActiveBuffer, BlobIndex)); end; //************************************************************************************* Display a message box containing system-level information about client application. This example uses the following input: ShowClientInfo; The procedure is defined as: procedure ShowClientInfo; const InfoStr = 'Name: %s'#13#10'Number of sessions: %d'#13#10 + 'Working directory: %s'#13#10'Language: %s'; var ClientInf: ClientInfo; begin Check(DbiGetClientInfo(ClientInf)); with ClientInf do ShowMessage(Format(InfoStr, [szName, iSessions, szWorkDir, szLang])); end; //************************************************************************************** Return the handle associated with the current session: If a call to DbiStartSession has occurred previously, then this function returns a handle to the current session. This example uses the following input: fDbiGetCurrSession(hSes); The procedure is defined as: procedure fDbiGetCurrSession(var hTmpSes: hDBISes); begin Check(DbiGetCurrSession(hTmpSes)); end; //************************************************************************************** Return an existing cursor for the given table within the current session. This function also returns the name of the index on which the table is open. This example uses the following input: OutputStr:= fDbiGetCursorForTable(Table1.DBHandle, Table1.TableName, MyNewCursor); The function is defined as: function fDbiGetCursorForTable(hTmpDb: hDbiDb; TblName: string; var hNewCur: hDBICur): string; var IndexDesc: IdxDesc; begin Check(DbiGetCursorForTable(hTmpDb, PChar(TblName), '', hNewCur)); Check(DbiGetIndexDesc(hNewCur, 0, IndexDesc)); Result := StrPas(IndexDesc.szName); end; //***************************************************************************************