Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

How to programmatically interact with a MS Access Database

Posted on 2003-03-11
2
Medium Priority
?
270 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
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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

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. …
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
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 goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…

580 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