BpcSMScriptLibrary 6

From RiskWiki
Jump to: navigation, search

ADO Database Connection Utility routines

Language: Delphi 7 - 2007

//////// ADO Database Connection Utility routines

uses sysutils, Types, classes, DB, ADODB, JclStrings, JclSysUtils;

// Routines for managing the bpcSMDataModule Standard
// Assumes a datamodule with the following components

// Change the database connection to NewDb and return the new connection string or the old one if no change made.
// (Assumes AdoConnection has a pre-existing valid Db connection)
function bpcChangeADODBConnectionTo( AdoConnection : TADOConnection; WithRegistryReset: boolean; NewDb: string): string;
// Return the name of the current database in the connectionstring
function bpcGetCurrentADODBName(AdoConnection : TADOConnection): string;
// Check whether the current Db is connectable and return the Db to the pre-test state
function bpcIsADODBConnectable(AdoConnection : TADOConnection): boolean;
// Copy a list of database names (containing Filter if not '') on the server in 'List' and return true if everything is successful, else false
function bpcGetADODBNames( AdoConnection : TADOConnection; LoginPrompt : boolean; Filter:string; List: TStrings) : boolean;
// Reconnect the datamodule returning true if successful, and false if error or otherwise unsuccesful. (Always forces disconnect first)
function bpcReConnectDataModule( AdoConnection : TADOConnection): boolean;