ASP'NET Database Connectivity 3 - PowerPoint PPT Presentation

1 / 12
About This Presentation
Title:

ASP'NET Database Connectivity 3

Description:

GridView automatically generates a column for every field ... Close() Closes the data reader. 11. Accessing a Column in a DataReader. Example: ... – PowerPoint PPT presentation

Number of Views:42
Avg rating:3.0/5.0
Slides: 13
Provided by: saxserv
Category:

less

Transcript and Presenter's Notes

Title: ASP'NET Database Connectivity 3


1
ASP.NET Database Connectivity 3
2
Outline
  • Format GridView
  • Review Do while loop
  • Try and Catch blocks
  • More about DataReader class
  • ListItem class

3
GridView
  • GridView automatically generates a column for
    every field
  • AutoGenerateColumns property is True by default
  • To change the display format, you need to
  • set AutoGenerateColumns to False
  • define columns using ltColumnsgt tag

4
ltColumnsgt
  • You can
  • hide columns
  • change the order of the fields
  • change column header
  • ltBoundFieldgt
  • This type of column displays text from a field in
    the data source

5
The Do While . Loop
  • Do While condition is true
  • statement(s)
  • Loop

6
Flowchart for a Do While Loop
Is the condition true
No
Yes
Execute statements within the loop
Execute statements that follow the loop
7
The Do While . Loop
  • Is executed as long as the condition is True.
  • If condition is False then the next statement
    after the Loop is executed.

8
Try and Catch Blocks
  • It handles exception (errors)
  • When exception occurs in a Try block, a
    corresponding Catch blick catches the exception
    and handles it gracefully
  • At least one Catch block or a Finally block must
    follow a Try block

9
Finally Block
  • This block guaranteed to execute regardless of
    whether the try block has errors or not
  • It is an ideal location to place resource-release
    code for resources (e.g. files, connections etc.)
    that are used earlier

10
DataReader class
  • Methods
  • Read()
  • Reads the next row. Returns True if there is at
    least one row otherwise, returns False
  • Close()
  • Closes the data reader

11
Accessing a Column in a DataReader
  • Example
  • Dim dr As System.Data.OleDb.OleDbDataReader
  • Lable1.Text dr(FirstName)

12
ListItem
  • Properties
  • Text the text displayed for the list item
  • Value value associated with the list item
  • Usually theyre the same
  • Methods
  • Add(ListItem) adds an item
  • Clear removes all items
Write a Comment
User Comments (0)
About PowerShow.com