Introduction to ADO 2

Embed Size (px)

Citation preview

  • 8/8/2019 Introduction to ADO 2

    1/16

    Welcome to Database Programming.MS Access DB Objects

  • 8/8/2019 Introduction to ADO 2

    2/16

    Database Table Fundamentals...

    Data is stored in tables.

    The data is arranged in rows & columns much like aspreadsheet....

    Your Access DB has a .MDB file extension

  • 8/8/2019 Introduction to ADO 2

    3/16

    Database Table Fundamentals...

  • 8/8/2019 Introduction to ADO 2

    4/16

    You use design view in Access to create your table. You control the data typefor the field and you make a unique or primary field which identifies eachrecord. CustID is my primary field. Notice the small key symbol.

  • 8/8/2019 Introduction to ADO 2

    5/16

    ADO DataBase Model(Active-XData Access Objects)

    Step 1: The Connection object is used to talk to theDB. We give it the location and type of db and itknows how to communicate with our DB.

  • 8/8/2019 Introduction to ADO 2

    6/16

    ADO DataBase Model(Active-XData Access Objects)

    Step 2: The Data adapter is used to actuallyread/write our data. It is designed specifically for thetype of DB we are using. For MS ACCESS, we use theOleDbDataAdapter control.

  • 8/8/2019 Introduction to ADO 2

    7/16

    ADO DataBase Model(Active-XData Access Objects)

    Step 3: We use a DataSet to hold our data in RAM.We actually work with this data and we do not directlymanipulate the DB table. A dataset can hold morethan one table of information if you like.

  • 8/8/2019 Introduction to ADO 2

    8/16

    ADO DataBase Model(Active-XData Access Objects)

    Step 4: We use controls on our form to display thedata. Each textbox is bound to or associated with afield in the DB table we are using. We can use buttonsto navigate through the dataset to display ourrecords.

  • 8/8/2019 Introduction to ADO 2

    9/16

    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 NewData Source.

  • 8/8/2019 Introduction to ADO 2

    10/16

    Step 2: The control will launch the Configuration wizard

  • 8/8/2019 Introduction to ADO 2

    11/16

    Step 3: Choose New connection and browse to your .mdb file thenclick next.

  • 8/8/2019 Introduction to ADO 2

    12/16

    Step 4: Change the data source to MS Access and navigate to thedatabase using the browse button. Choose Yes if you want theDB to be copied to the project folder or not.

  • 8/8/2019 Introduction to ADO 2

    13/16

    Step 5: You can decide to copy the connection string to theproject folder in the app_config file. This is a good idea sochoose Yes.

  • 8/8/2019 Introduction to ADO 2

    14/16

    Step 6: Add the table you want to use and click finish. We willselect all fields. Or you can click on the ones you want thenclick Finish.

  • 8/8/2019 Introduction to ADO 2

    15/16

    Step 7: You will then see the table with your data displayed. Forthis project, we did not allow edit, updates, or deletes.

  • 8/8/2019 Introduction to ADO 2

    16/16

    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 tochange those so they say exactly what you want.