You are on page 1of 3

AACS4134 Internet Programming

Tutorial 4B 1. DataSet has the ability to hold more than one set of data. Evaluate this statement. DataReader only fetch one set of the data from a database, but the DataSet has the ability to hold more than one set of data. It does this by having a Tables collection containing a Table object for each set of data. Even table in turn has a Rows collection with Row object for each of data. 2. What is the role of DataAdapter? The DataAdapter is special class whose purpose is to bridge the gap between the disconnected DataTable objects and the physical data source.
3. DataSet actually provides a simple container for disconnected data.

Evaluate this statement. The reason for designing such a (disconnected) model is better performance the less time you spend connected to the database, the better the database can run. 4. How do you know that a server control can be bind to a data source? Answer If a server control has a DataSource property and DataBind method, then it can be bind to a data source. DataSource property provides an interface that allows the selected data from a data source pass into a server control. DataBind() method is use to retrieve the selected data from a data source and then pass it into the server control.
5. Based on the information given below, provide few lines of codes to show

how you bind the DataRepeater control to a data source. Object Command DataReader DataRepeater cmdDisplay dtrCustomer rptCustomer Name

Answer dtrCustomer = cmdDisplay.ExecuteReader(); // Bind to Repeater rptCustomer.DataSource = dtrCustomer;


__________________________________________________________________________________ Chapter 4: Database Programming

AACS4134 Internet Programming

rptCustomer.DataBind(); 6. What are the benefits of using the Repeater control? Answer - Can format the display outlook. - Can select the data field that wanted to display to the web users. - etc
7. Based on the information given below, provide few lines of codes to show

how you bind the CheckBoxList control to a data source. Object Name SQL Select statement Select name,phone From Customers Command cmdDisplay DataReader dtrCustomer DataRepeater rptCustomer CheckBoxList chklDisplay
Answer

cmdDisplay = new OleDbCommand("Select name, phone From Customers ", conPubs); dtrCustomer = cmdDisplay.ExecuteReader(); chklDisplay.DataSource = dtrCustomer; chklDisplay.DataTextField = "name"; chklDisplay.DataBind();

or

cmdDisplay = new OleDbCommand("Select name, phone From Customers ", conPubs); dtrCustomer = cmdDisplay.ExecuteReader(); chklDisplay.DataSource = dtrCustomer; chklDisplay.DataTextField = "phone"; chklDisplay.DataBind();

__________________________________________________________________________________ Chapter 4: Database Programming

AACS4134 Internet Programming

8. Given 2 methods to enter the items value for the DropDownList control: i. We can go to the Propeties Window for the DropDownList control, then click the Items property, and then add the items and enter their value. Programatically using the C#.NET code, bind the DropDownList control to a data source.

ii.

Which method is the best method? Discuss about it. Answer (i) Method (i): the items are fixed. (ii) Method (ii): the number of items are large, and items can be produced dynamically using codes (iii) Method (ii): the items are not static (dynamic), can bind to a database table.

__________________________________________________________________________________ Chapter 4: Database Programming

You might also like