• home
  • forum
  • my
  • kt
  • download
  • Work with data: insert, delete and update. Sorting and Grouping. {Tutorial for beginners}

    Author: 2007-09-03 09:52:51 From:

    Datasheet
     
    A datasheet is the visual representation of the information contained in a database table, or of the results returned by a query. When you add or remove a column from a datasheet, you add or remove a field from the table that underlies the datasheet. If that field contains data, you also eliminate that information. 
     
    You can use the datasheet view to add, change, delete, sort or filter records from a database table. 
     
    In this tutorial, you will work with the TutorialSource database. 
     
     
    Changing records
     
    1) Open TutorialSource database.
     
    Illustration 1: Tables that belongs to the Tutorial Source Database.  Click here to view larger image.
     
    2) Double click on Areas table to open the datasheet view.
     
    Illustration 2: Areas table at datasheet view.  Click here to view larger image.
     
    3) Select the first record and change the AreaId field content. Change the value 2 by 8.
     
    4) Press the Tab key to jump to the Area field.
     
    5) Modify the value with ¡°Engineering¡±.
     
    6) Press Tab key to jump to the next record.
     
    Illustration 3: The first record data and record Id are updated.
     
    7) At second record, change the actual value in AreaId field. Place a 9.
     
    8) Press the Tab key to move to the next field. Change it by ¡°Quality Assurance¡±.
     
    9) Press the Tab key to move to the next record.
     
    10) Close the datasheet view. A window asking for save changes will appear. Press the YES button.
     
    Illustration 4: You must save the changes.  Click here to view larger image.
     
    11) When you close the datasheet view. A window asking for save changes will appear.
     
    12) Open the Areas table in Design View. As you can see, this table does not have a Primary key. Select the AreaId field and create a primary key.
     
    Illustration 5: Press the Primary key command to create the key.
     
    13) Close the Design view window and try to save changes.
     
    Illustration 6: Press the YES button.
     
    14) Close the Design view window and try to save changes.
     
    Illustration 7: Error message raised by the application.  Click here to view larger image.
     
    This error message is indicating that there are duplicates keys for the field selected as Primary Key. As you can see at illustration 3, there are two records with AreaId = 6.
     
    15) Open the Areas table in datasheet view and change the AreaId field another value.
     
    Illustration 8: Select a non repeated value for the key.
     
    16) Repeat the steps to create the primary key and save the changes. This time, you will not receive the error message.
     
    17) Try to modify another record by changing the AreaId field and using a duplicated value. You will receive another error message.
     
    Illustration 9: When you try to insert a duplicated value in the key field, the error will be raised.  Click here to view larger image.
     
    Adding records
     
    18) Open the Areas table in datasheet view.
     
    19) Insert a new non-duplicated value in the AreaId field.
     
    20) Insert text data in the Area field.
     
    Illustration 10: insert a new record.  Click here to view larger image.
     
    Deleting records
     
    21) Open the FileTypes table in datasheet view.
     
    22) Select an entire row.
     
    23) Press the DEL key.
     
    Illustration 11: Press the YES button to delete the selected record.  Click here to view larger image.
     
    If there are related records in other tables, the operation will fail and an error messages will be raised.
     
    Deleting records
     
    24) Open the Files table in datasheet view.
     
    25) Select the FileName column by clicking in his title.
     
    Illustration 12: Select the Filename column.  Click here to view larger image.
     
    26) Press the Ascending button to sort records in ascending order by Filename field.
     
    Illustration 12: Select the Filename column.
     
    Illustration 14: The records will be sorted by File Name.  Click here to view larger image.
     
    Filtering records
     
    27) Open the Files table in datasheet view.
     
    28) Select the AreaId column by clicking in his title.
     
    Illustration 15: Select the AreaId column.  Click here to view larger image.
     
    29) Press the Filter button to sort filter records.
     
    Illustration 16: Select Filter button.
     
    30) The Filter window will be opened showing the order options and a list with available values for this field. You can select one or more filtering values.
     
    Illustration 17: Available filter values.  Click here to view larger image.
     
    31) Click on Select All option to deselect all values.
     
    Illustration 18: All filtering options will be cleared.  Click here to view larger image.
     
    32) Click on 4 option to and press the OK button to apply the filter.
     
    Illustration 19: All records where the AreaId match the filter will be showed.  Click here to view larger image.

    discuss this topic to forum

    relation tutorial

    No relevant information

    Category

      Miscellaneous (10)

    New

    Hot