JavaScript EditorJavascript debugger     Javascript examples


Team LiB
Previous Section Next Section

Chapter 9 Quick Reference

To

Do this

Connect to a SQL Server database

Create and open an instance of the SqlConnection class from the System.Data.SqlClient namespace.

Connect to an OLE DB datasource

Create and open an instance of the OleDbConnection class from the System.Data.OleDb namespace.

Execute SELECT, UPDATE, INSERT, or DELETE statements against a database

Create an instance of the SqlCommand or OleDbCommand class, define a query, and call one of its Execute methods.

Use an in-memory cache of hierarchical data

Create an instance of the DataSet class from the System.Data namespace. Populate the dataset by calling the Fill method of the SqlDataAdapter or OleDbDataAdapter class.

Display read-only data in a bound control

Bind the control to a SqlDataReader or an OleDbDataReader. Be sure to pass the CommandBehavior.CloseConnection argument to the ExecuteReader method when creating the datareader. This ensures that the underlying connection is closed when the datareader is closed.

Bind data to a control

Set the DataSource property of the control to the DataReader, DataView, or other data source, and then call the DataBind method of the control (or call the page’s DataBind method).

Edit bound data in a DataGrid

Add an Edit, Update, Cancel button column using the Property Builder, and add event handlers for Edit, Update, and Cancel in code.

Delete bound data in a DataGrid

Add a Delete button column using the Property Builder, and add a Delete event handler in code.

Display bound data in multiple columns

Use a DataList control and set the RepeatColumns attribute to the number of columns desired.

Display bound data with the greatest possible flexibility

Use a Repeater control, and manually add HTML code, along with data-binding directives.


Team LiB
Previous Section Next Section


JavaScript EditorJavascript debugger     Javascript examples