10 pts.
 connectivy between C++ and MS Access
hi, i have problem releted with ms acess and c++ programming languge sir cant get any information about connection between ms acess and c++ programming languge give me steps to connect ms acess and c++

Software/Hardware used:
turbo c++ and ms acess
ASKED: January 26, 2010  9:11 AM
UPDATED: January 27, 2010  10:27 PM

Answer Wiki:
Here's an example from the MSDN library (VS 6): <b>In the following example, an application allocates environment and connection handles. It then connects to the SalesOrders data source with the user ID JohnS and the password Sesame and processes data. When it has finished processing data, it disconnects from the data source and frees the handles.</b> <pre> SQLHENV henv; SQLHDBC hdbc; SQLHSTMT hstmt; SQLRETURN retcode; /*Allocate environment handle */ retcode = SQLAllocHandle(SQL_HANDLE_ENV, SQL_NULL_HANDLE, &henv); if (retcode == SQL_SUCCESS || retcode == SQL_SUCCESS_WITH_INFO) { /* Set the ODBC version environment attribute */ retcode = SQLSetEnvAttr(henv, SQL_ATTR_ODBC_VERSION, (void*)SQL_OV_ODBC3, 0); if (retcode == SQL_SUCCESS || retcode == SQL_SUCCESS_WITH_INFO) { /* Allocate connection handle */ retcode = SQLAllocHandle(SQL_HANDLE_DBC, henv, &hdbc); if (retcode == SQL_SUCCESS || retcode == SQL_SUCCESS_WITH_INFO) { /* Set login timeout to 5 seconds. */ SQLSetConnectAttr(hdbc, (void*)SQL_LOGIN_TIMEOUT, 5, 0); /* Connect to data source */ retcode = SQLConnect(hdbc, (SQLCHAR*) "Sales", SQL_NTS, (SQLCHAR*) "JohnS", SQL_NTS, (SQLCHAR*) "Sesame", SQL_NTS); if (retcode == SQL_SUCCESS || retcode == SQL_SUCCESS_WITH_INFO){ /* Allocate statement handle */ retcode = SQLAllocHandle(SQL_HANDLE_STMT, hdbc, &hstmt); if (retcode == SQL_SUCCESS || retcode == SQL_SUCCESS_WITH_INFO) { /* Process data */ ...; ...; ...; SQLFreeHandle(SQL_HANDLE_STMT, hstmt); } SQLDisconnect(hdbc); } SQLFreeHandle(SQL_HANDLE_DBC, hdbc); } } SQLFreeHandle(SQL_HANDLE_ENV, henv);</pre> You will have to create an ODBC data source for your access database. I wrote an application like this many years ago, but I'm not able to find it to post the code. Though I remember it was pretty similar to the example above. You might want to investigate the following functions as well: SQLAllocStmt SQLBindCol SQLExecDirect SQLFetch Hope this helps.
Last Wiki Answer Submitted:  January 27, 2010  10:27 pm  by  carlosdl   63,580 pts.
All Answer Wiki Contributors:  carlosdl   63,580 pts.
To see all answers submitted to the Answer Wiki: View Answer History.


Discuss This Question:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _