Database connectivity between Microsoft Access and C++

5 pts.
Tags:
C
Database connectivity
Database programming
Microsoft Access
How can I give database connectivity in code of C++, and my database is stored in Microsoft Access?

Answer Wiki

Thanks. We'll let you know when a new response is added.

Here is an example, using ODBC, and functions from sql.h

SQLHENV henv;
SQLHDBC hdbc;
SQLRETURN rc;
SQLCHAR server[12];
SQLCHAR uid[12];
SQLCHAR pwd[12];
.
.
.
strcpy((char*)server, "test_db");
strcpy((char*)uid, "Admin");
strcpy((char*)pwd, "");
SDWORD cbName = SQL_NTS;

if (((rc = SQLAllocEnv(&henv)) == SQL_SUCCESS) &&
((rc = SQLAllocConnect(henv, &hdbc)) == SQL_SUCCESS))
{
if ((rc = SQLConnect(hdbc, server, SQL_NTS, uid, SQL_NTS, pwd, SQL_NTS)) != SQL_SUCCESS)
print_error (henv, hdbc, SQL_NULL_HSTMT, rc, __LINE__, __FILE__);

}
else
{
print_error (henv, SQL_NULL_HDBC, SQL_NULL_HSTMT, rc, __LINE__, __FILE__);
}

Have a look at this MSDN document: Developing Access 2007 Solutions with Native C or C++

Discuss This Question:  

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

Thanks! We'll email you when relevant content is added and updated.

Following

Share this item with your network: