I am a real newborn in ODBC and try to learn by the example before diving in the theory.
I wish to simply retreive records from a MS access 97 database called IB_Flows.mdb.
In my MFC project, things are initialized like this:
if (m_Path == _T(""))
return _T("DSN=MS Access 97 Database;DBQ=H:\\IB_Flows.mdb;DefaultDir=H:\\;DriverId=281;FIL=MS Access;MaxBufferSize=2048;PageTimeout=5;UID=admin;");
CString sz = _T("DSN=MS Access 97 Database;DBQ=");
sz = sz + m_Path;
sz += _T(";DefaultDir=H:\\;DriverId=281;FIL=MS Access;MaxBufferSize=2048;PageTimeout=5;UID=admin;");
There you can see that:
Default database: H:\\IB_Flows.mdb
DSN: MS Access 97
Please, how should I retreive the records in H:\\IB_Flows.mdb ?
Your code seems to take account only of DSN, but I want to connect to a .mdb file ! when should I input that?
Thanks a lot .
considering how old this is, I'm a little hesitant to even comment on it. The class is a good start, but has a long way to go before it becomes very useful. For example, needs an Open() with UserName and Authentication (Password) parameters instead of just defaulting these two to empty strings. Also a Close() method so that the same object can be reused with different database connections.
The test example program is simply awful. It won't even run without errors and I had to make a lot of changes.
I was having a steady memory leak while using this class, and I finally found the culprit. In the ExecuteSQL() function, the ::SQLFreeHandle(SQL_HANDLE_STMT, &hstmt)
call to release the statement handle is incorrect. It should be ::SQLFreeHandle(SQL_HANDLE_STMT, hstmt) where the handle is passed in, not the address of the handle.
Other than that, the class works quite well. I have made extensive modification in the error checking and handling area which I may offer up once I am finally done with this project.
I downloaded and unzip the demo project, and src files. I got "cannot open include file 'CODBCDynamic.hpp' no such file or dir", even i tried it by inserting that class by using (Menu bar)project-add to project-files and in (workspace)Header files-add files to folder, etc. Even then it returns error. Please tell where the mistake is?
Hari R K