To Notes

Lecture Summary for IT 236 on 7/6/06

 

Review Questions

  1. What is a relational database?

    Ans: A database that contains one or more rectangular tables.

  2. What does SQL mean?

    Ans: Structured Query Language.

  3. What does a SELECT statement do?

    Ans: It extracts a subset of the data (some of the rows and some of the columns) of a table.

  4. What does * mean in a SELECT statement?

    Ans: Select all of the columns.

  5. Using the PersonData Table write SELECT statements that do the following:

    1. Find the ages of all persons with name Bob or Robert. Ans:

      SELECT Age FROM PersonData
          WHERE Name = 'Bob' OR Name = 'Robert'

    2. Find the names of all teenage girls. Ans:

      SELECT Name FROM PersonData
          WHERE 13 <= Age AND Age <= 19

    3. Sort the table by age. Ans:

      SELECT * FROM PersonData
          ORDER BY Age

    Here is the PersonData table:
    Name Gender Age
    Mary F 23
    Robert M 31
    Sally F 35
    Jane F 28
    Tony M 30
    Alice F 41
    Scott M 27
    Larry M 49

  6. Redo the PhoneBook Example using the database PhoneNumbers.mdb in PhoneNumbers.zip.

    Ans: See the PhoneBookDB Example.

  7. What is a provider?

    Ans:

    A provider is the software that obtains data from a database of a specified format, and translates the data into a form that VB.NET can use.

  8. What are the four providers that can be used by VB.NET?

    Ans:

    OleDB, ODBC, Oracle, SQLServer. Other providers are also possible but do not automatically come shipped with VB.NET.

  9. Place these objects in order:
    DataAdapter    Connection    DataSet    Command    BoundControl

    Ans:
    Connection    Command    DataAdapter    DataSet    BoundControl

  10. What two pieces of information are essential in the ConnectionString property of a Connection object?

    Ans: Provider and dataset name.

  11. What does a DataAdapter object do?

    Ans: It extracts a table of data from the connection in a form that can be copied into a dataset.

  12. Write code that creates an OleDB data adapter object.

    sc.CommandText = sqlString
    Dim da As New OleDbDataAdapter
    da.SelectCommand = sc

  13. What is a DataSet object?

    Ans: XML data in memory representing a table from a database extracted with a select statement.

  14. What are data bindings?

    Ans: A data binding is an object that associates a property of a control with a column of a table. When the current row in the table is changed, the corresponding property changes automatically.

  15. Write a Click event handler for the button btnMoveLast that fills the DataSet object personDataSet and then moves to the last row in personDataSet. Ans:

    Dim n as Integer = da.Fill(ds, tableName)
    Me.BindingContext(ds, tableName).Position = n - 1

  16. Explain the difference between Methods 1, 2 and 3 when accessing a database using ADO.NET.

    Ans: Method 1 uses wizards to set up the database objects and uses data bindings. Method 2 uses code to set up the database objects and uses data bindings. Method 3 uses code to set up the database objects and does not use data bindings.

  17. Write a Windows application that accesses the PersonTable in the database persons.mdb contained in persons.zip using Method 2.

    Here is the table PersonData.
    Name Gender Age
    Mary F 23
    Robert M 31
    Sally F 35
    Jane F 28
    Tony M 30
    Alice F 41
    Scott M 27
    Larry M 49

    Ans: See the PersonsMethod2 example.

  18. Write a statement without using data binding that assigns to the textbox txtAge, the age from the current row of the PersonData table stored in the dataset ds. Assume that PersonData is the only table in ds.

 

Two New Controls

 

The FlightInfo2 Project

 

Menus and MenuItems

 

The Random Object

 

Practice Problems

  1. Write a Console application that simulates 60,000 rolls of a die. Count how many sixes are obtained.

    Ans: See the DieRolls (W) example.

  2. Write a Console application that rolls a pair of dice repeatedly. Count how many rolls are needed to roll snake eyes (a pair of ones).

    Ans: See the SnakeEyes (W) example.

 

Drawing in a PictureBox Control

 

Capturing Mouse Data

 

Creating Controls Dynamically

 

The OpenFileDialog Control