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 ms-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

<pre> 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__);
}
</pre>

Have a look at this MSDN document:

<a href=”http://msdn.microsoft.com/en-us/library/cc811599.aspx”>Developing Access 2007 Solutions with Native C or C++</a>

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.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

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.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

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

Following