[odbc] bipfile - fonctions d'accès aux bases de données

Description

Les fonctions BipFILE ont pour but de faciliter l'accès aux bases de données.

Les bases gérées actuellement sont Microsoft Jet (=Access), Microsoft SqlServeur et MySQL.
Les accès se font via ODBC. Les fonctions supportent nom d'utilisateur, mot de passe, port, trusted connection, nom du serveur, ...
La description des tables ou requètes est chargée automatiquement dans des structures en mémoire.
Documentation complète ici : http://bipcpp.free.fr/

Un exemple des fonctions :
- pour ouvrir une table : BF_TableOpen
- pour lancer une requète SELECT : BF_SQLQueryOpen
- pour lancer une commande INSERT, ALTER, DELETE ... : BF_SQLCommand
- pour lire un enregistrement : BF_RecordReadNext
- pour récupérer les valeurs : BF_FieldValueGetString, BF_FieldValueGetInteger, BF_FieldValueGetDate, ...
- pour fermer la table : BF_TableClose

Source / Exemple :


Un extrait du .h :
--------------------

	// table functions
	int BF_TableOpen (const string sBFName, const string sBFTableName, const string sBFDbName,
				  const string sBFSrvName, const string sBFDbType, const string sBFParam = "");
				  // sBFParam = ""
	int BF_TableClose (const string sBFName);
	BF_STRUCT_TABLE BF_TableGet (const string sBFTable);
	BF_STRUCT_TABLE BF_TableNullGet (void);
	int BF_SQLRecordDescriptionLoad (const string sBFName);
	int BF_SQLQueryDescriptionLoad (const string sBFName);
	int BF_BDBRecordDescriptionLoad (const string sBFName);
	int BF_BDBRecordDescriptionSave (const string sBFName, const string sBFRecord);

	// field functions
	int BF_FieldAdd (const string sBFName, const string sBFFieldName,
					const string sBFInterType, const int iBFFieldLength,
					const string sBFDbType, const bool bBFDbNull,
					const string sBFDbRemark = "", const string sBFDbDefValue = "",
					const int iBFDbDecimal = 0);
					// sBFDbRemark = "", sBFDbDefValue = "", iBFDbDecimal = 0
	BF_STRUCT_FIELD BF_FieldGet (const string sBFTable, const string sBFField);
	string BF_FieldNameGet (const string sBFTable, const int iBFOrder);
	string BF_FieldValueGetString (const string sBFName, const string sBFField);
	string BF_FieldValueGetString (const string sBFName, const int iBFOrder);
	long BF_FieldValueGetInteger (const string sBFName, const string sBFField);
	long BF_FieldValueGetInteger (const string sBFName, const int iBFOrder);
	LONGLONG BF_FieldValueGetLongLong (const string sBFName, const string sBFField);
	LONGLONG BF_FieldValueGetLongLong (const string sBFName, const int iBFOrder);
	double BF_FieldValueGetFloat (const string sBFName, const string sBFField);
	double BF_FieldValueGetFloat (const string sBFName, const int iBFOrder);
	BP_Date BF_FieldValueGetDate (const string sBFName, const string sBFField);
	BP_Date BF_FieldValueGetDate (const string sBFName, const int iBFOrder);
	BP_Currency BF_FieldValueGetCurrency (const string sBFName, const string sBFField);
	BP_Currency BF_FieldValueGetCurrency (const string sBFName, const int iBFOrder);
	BF_STRUCT_FIELD BF_FieldNullGet (void);
	int BF_FieldSetString (const string sBFName, const string sBFField,
						const string sBFValue, const bool bBFNull = false);
						// const bool bBFNull = false
	int BF_FieldSetInteger (const string sBFName, const string sBFField,
						const long lBFValue, const bool bBFNull = false);
						// const bool bBFNull = false
	int BF_FieldSetLongLong (const string sBFName, const string sBFField,
						const LONGLONG llBFValue, const bool bBFNull = false);
						// const bool bBFNull = false
	int BF_FieldSetFloat (const string sBFName, const string sBFField,
						const double dBFValue, const bool bBFNull = false);
						// const bool bBFNull = false
	int BF_FieldSetDate (const string sBFName, const string sBFField,
						BP_Date dtBFValue, const bool bBFNull = false);
						// const bool bBFNull = false
	int BF_FieldSetCurrency (const string sBFName, const string sBFField,
						BP_Currency curBFValue, const bool bBFNull = false);
						// const bool bBFNull = false
	BF_STRUCT_FIELD BF_SQLQueryFieldGet (const string sBFTable, const int iBFOrder);

	// record functions
	int BF_RecordReadNext (const string sBFName);
	int BF_RecordSave (const string sBFName);
	int BF_RecordPrepare (string sBFName);

	// SQL functions
	string BF_SQLQueryOpen (const string sBFQueryName, const string sBFSQLQuery,
					 const string sBFDbName, const string sBFSrvName,
					 const string sBFDbType, const string sBFParam = "");
				  // sBFParam = ""
	string BF_SQLCommand (const string sBFSQLCommand, const string sBFDbName,
					  const string sBFSrvName, const string sBFDbType, const string sBFParam);
	string BF_SQLConnectStringGet (const string sBFDbName, const string sBFSrvName,
							   const string sBFDbType, const string sBFParam);

	// other functions
	void BF_ResetBipFILEIntl (void);
	void BF_ErrorSet (const string sBFName, const string sBFFunction, const string sBFParam);
	string BF_ErrorDisplay (const int iBFError);
	void BF_ErrorDisplaySet (const bool bBFError = true, const bool bBFWrite = false);
				// bBFError = true, bBFWrite = false

	string BF_IntToString (const long iLong);
	int BF_StringToInt (const string sString, const int iBase = 10);
				// iBase = 10
	string BF_LongLongToString (const LONGLONG iLong);
	LONGLONG BF_StringToLongLong (const string sString);
	string BF_DoubleToString (const double dDouble);
	string BF_StringToUpper (const string sString);
	string BF_StringParamGetIntl (const string sBFParam, const string sBFString);
	bool BF_StringIsTrue (const string sBFInput);
	bool BF_StringIsFalse (const string sBFInput);

Conclusion :


En exemple, vous trouverez un frontal SQL (voir copie d'écran) qui permet de lancer toutes les requètes SQL (SELECT, UNION, HAVING, GROUP BY, ...) et commandes SQL (ALTER, DROP, INSERT, UPDATE, DELETE, ...) reconnues par la base SQL.

La source et l'executable sont ici : http://bipcpp.free.fr/fr/bipfile/demosql-v110.zip

C'est un exe de 330 ko qui est autonomme, pas d'installation, pas de modification de la base de registre, ...
le seul prérequis est l'installation du driver ODBC de votre base de données.

Codes Sources

A voir également

Vous n'êtes pas encore membre ?

inscrivez-vous, c'est gratuit et ça prend moins d'une minute !

Les membres obtiennent plus de réponses que les utilisateurs anonymes.

Le fait d'être membre vous permet d'avoir un suivi détaillé de vos demandes et codes sources.

Le fait d'être membre vous permet d'avoir des options supplémentaires.