1. Trang chủ
  2. » Công Nghệ Thông Tin

Tài liệu Chapter 23 Quick Reference pptx

1 379 0

Đang tải... (xem toàn văn)

THÔNG TIN TÀI LIỆU

Thông tin cơ bản

Định dạng
Số trang 1
Dung lượng 21,62 KB

Nội dung

Chapter 23 Quick Reference To Do this Create a connection to a database graphically in Visual Studio 2005. Use the Data Source Configuration Wizard. The wizard prompts you for the details of the connection to create and the database objects to use. Browse data in Visual Studio 2005. In the Data menu, click Preview Data. The Preview Data dialog box allows you to select a DataSet and DataTable object. Click the Preview button to view the data. Change the way in which a DataTable will be presented on a form. In the Data Sources window (click Show Data Sources on the Data menu if this window is not displayed) click the DataTable. Select the style (DataGridView, Details, or None) from the drop-down menu that appears. Modify the way in which fields in a data source will be displayed on a form. In the Data Sources window, expand the DataTable containing the fields to be modified. Click the field, and select the presentation style from the drop-down menu that appears. Add a DataTable to a form. Click and drag a DataTable object from the Data Sources window onto the form. Either a collection of fields or a DataGridView is added to the form. Visual Studio 2005 also generates a DataSet, a BindingSource, a TableAdapter, and a BindingNavigator object for connecting the form fields or DataGridView to the database and moving through the data. Programmatically connect to a database. Create an SqlConnection object, set its ConnectionString property with details specifying the database to use, and call the Open method. Create and execute a database query in code. Create an SqlCommand object. Set its Connection property to a valid SqlConnection object. Set its CommandText property to a valid SQL SELECT statement. Call the ExecuteReader method to run the query and create an SqlDataReader object. Fetch data by using a SqlData-Reader object. Ensure the data is not null by using the IsDBNull method. If the data is not null, use the appropriate GetXXX method (such as GetString or GetInt32) to retrieve the data.   . Chapter 23 Quick Reference To Do this Create a connection to a database graphically

Ngày đăng: 15/12/2013, 00:15

w