×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

DataBase & C++

DataBase & C++

DataBase & C++

(OP)
Hi All,

I wanted to learn to access database through C++ programming.Unfortunetly I only have Ms-Access in my system. Can any one send some sample programms to access data from MS-Access database so that I can learn it easly. I have Bcc32(Borland) compailer.

If you have sample code you please forward to swaroop67@hotmail.com


Regards,

Swaroop.

RE: DataBase & C++

This code is the basical code of ODBC API. It is easy to learn and to understand. I didn't put there the errors handling.

#include<sql.h>
char* DSN ="Driver={Microsoft Access Driver(*.mdb)};
DBQ=c:\\temp\\sample.mdb";
int main()
{
  HENV hEnv;
  SQLAllocEnv(&hEnv);
  HDBC hDbc;
  SQLAllocConnect(hEnv,&hDbc);
  SQLDriverConnect(hDbc,NULL,)
  SQLDriverConnect(hdbc, hwnd,
    (SQLTCHAR*)DSN, SQL_NTS,NULL,
    0,0, SQL_DRIVER_NOPROMPT);
  HENV hEnv;
  SQLAllocEnv(hDbc,&hEnv);
  SQLExecDirect(hEnv,"delete* from OneTable",SQL_NTS);
  SQLFreeEnv(Env);
  SQLDisconnect(hDbc);
  SQLFreeConnect(hDbc);
  SQLFreeEnv(hEnv);
}

John Fill

RE: DataBase & C++

For an easier database program, and more common (in my opinion, this is not designed to invite or promote flames) see www.mysql.com for a good alternative.



Disclaimer:
Beware: Studies have shown that research causes cancer in lab rats.

RE: DataBase & C++

Thankyou for your prompt reply.

Regards,

Swaroop.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close