|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Announcements
Chapters
Services
Feature Zones
|
IntroductionI have written a lot of database apps. Most of them have been small, and I soon realized that
the These classes are extremely basic, and provide little use for someone who does not use the ODBC API directly. However, for those of you that do use the API, you might find them useful.
There are three classes in this collection, CODBCCnx class
//connecting to a DBMS through a DSN, "foodsn"
Ok so now we are connected, lets disconnect from the database. The //disconnecting from above connection (dsn) dsn.Disconnect(); //this rolls all uncommitted transactions back //NOTE: dsn.Disconnect(SQL_ROLLBACK) is the same thing CODBCQuery classOk, so we have connected and disconnected, big deal. The nice thing about these classes is being able to share that
connection we just made. This is where //establish a connection using dsn CODBCCnx *pDsn = new CODBCCnx("foodsn", "username", "password"); CODBCQuery qry1, qry2; if(!pDsn->IsOk()) { //connected!! now lets share some connections :) pDsn->Connect(qry1.h_qstmt); pDsn->Connect(qry2.h_qstmt); } else{ //not connected } //or we can do everything in one step CODBCQuery qry(new CODBCCnx("foodsn", "username", "password"), true); //or we can take the pDsn and pass it to a bunch of new query objects CODBCQuery qry2(pDsn), qry3(pDsn,false); //or we can have the CODBCQuery class connect itself CODBCQuery qry4("SQL Server", "CompName", "username", "password"); //using a DSN CODBCQuery qry5(NULL, "foodsn", "username", "password"); As you can see in the above code snippet, the constructors for
One final note. There is a global function, The only thing left to do after all this connecting and sharing is to bind variables to result sets. Which I leave for you to do :) I didn't provide a demo, because I feel that these classes are too simple to warrant one. However, if you would like one give me a holler and I will gladdly provide you with one. Dependancies
If you look at the code, there are two files, strutil.h and strutil.cpp. They are very simple functions to handle History5 Nov 2001 - updated download
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||