?
Solved

How to programmatically interact with a MS Access Database

Posted on 2003-03-11
2
Medium Priority
?
265 Views
Last Modified: 2010-04-01
Hi everybody!
I use Borland BuilderC++5 and want to make my program interact with a MS Access Database. It's the first time i get involved with database applications, so i don't know how to programmatically interact with the database. What functions are there to allow me eg. add data or delete a record? What files should I #include?

I didn't find any help or tutorials on the subject(concerning builderC++) so, please,could someone post some code example??

Thank u in advance!
0
Comment
Question by:classobaniera
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 2

Accepted Solution

by:
BorlandMan earned 140 total points
ID: 8116885
uh,
for a simple quick approach, you don't need to write any code (heh heh). Simply drop a datasource, TTable and a dataAware grid on the form, connect them and voila'

with this kind of sample, there is no code necessary (yep it's that good)

ok, more detail:

Click on the ttable component on the form.
press F11 to display the Object Inspector.

Click on the databaseName property.
Click on the drop down list to the right of
  databasename entry. A drop downlist should
  appear showing you the various aliases

Click on TableName property and pick the
table name you want from the drop down list.


next drop a DbGrid on the form.
a. click on the datasource property, in the
drop down list to the right pick the datasource
you want to connect to (there should be one for
our example).

Now click on the datasource component
and pick the dataset property. In the list
there select the table (should be only 1)

finally click on the Table2 component. Set
the Active property to true. You should see
the data appear in your grid (cool).

oh and then if you want you can run the
program (hehheh)


the trick is setting up your database access. As in the TTable, you need to set the databaseName property and it's going to have to setup the database in the ODBC Administrator on your machine... then use the Borland Database Administrator (in your control panel) to associate the ODBC Datasource with an alias.

This alias will appear in the database dropdown list of your TTable and TQuery components, which you use in C++ builder to connect to a database.

of course, you can do it by hand, if you like, say using the ODBC SDK, however, the richness these components give you are really good and allow to you to develop apps faster.

hope this helps,
sincerely,
J
0
 
LVL 9

Expert Comment

by:tinchos
ID: 9481828
No comment has been added lately, so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area that this question is:

Answered by: BorlandMan

Please leave any comments here within the next seven days.

PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!

Tinchos
EE Cleanup Volunteer
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Errors will happen. It is a fact of life for the programmer. How and when errors are detected have a great impact on quality and cost of a product. It is better to detect errors at compile time, when possible and practical. Errors that make their wa…
What is C++ STL?: STL stands for Standard Template Library and is a part of standard C++ libraries. It contains many useful data structures (containers) and algorithms, which can spare you a lot of the time. Today we will look at the STL Vector. …
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question