Download as ppt, pdf, or txt
Download as ppt, pdf, or txt
You are on page 1of 16

Welcome to Database Programming.

MS Access DB Objects
Database Table Fundamentals...

•Data is stored in tables.


•The data is arranged in rows & columns much like a
spreadsheet....
•Your Access DB has a “.MDB” file extension
Database Table Fundamentals...
You use design view in Access to create your table. You control the data type
for the field and you make a unique or primary field which identifies each
record. CustID is my primary field. Notice the small key symbol.
ADO DataBase Model
(Active-X Data Access Objects)

Step 1: The Connection object is used to talk to the


DB. We give it the location and type of db and it
knows how to communicate with our DB.
ADO DataBase Model
(Active-X Data Access Objects)

Step 2: The Data adapter is used to actually


read/write our data. It is designed specifically for the
type of DB we are using. For MS ACCESS, we use the
OleDbDataAdapter control.
ADO DataBase Model
(Active-X Data Access Objects)

Step 3: We use a DataSet to hold our data in RAM.


We actually work with this data and we do not
directly manipulate the DB table. A dataset can hold
more than one table of information if you like.
ADO DataBase Model
(Active-X Data Access Objects)

Step 4: We use controls on our form to display the


data. Each textbox is “bound” to or associated with a
field in the DB table we are using. We can use
buttons to navigate through the dataset to display our
records.
Steps for Building a DB Front-End Application
Using a DataGridView Control...

Step 1:
 Create your form and rename it if
you like.
 Drag DataGridView Control to the form
 Use the smart tag to choose New
Data Source.
Step 2: The control will launch the Configuration wizard
Step 3: Choose New connection and browse to your .mdb file
then click next.
Step 4: Change the data source to MS Access and navigate to the
database using the browse button. Choose Yes if you want the DB
to be copied to the project folder or not.
Step 5: You can decide to copy the connection string to the
project folder in the app_config file. This is a good idea so
choose “Yes”.
Step 6: Add the table you want to use and click finish. We will
select all fields. Or you can click on the ones you want then
click “Finish”.
Step 7: You will then see the table with your data displayed. For
this project, we did not allow edit, updates, or deletes.
Step 8: Run your app. You can sort columns by clicking on a grid column.
Notice the column headers may not look too good. I will show you how to
change those so they say exactly what you want.

You might also like