Chapter 23 Quick Reference

Chia sẻ: Nghia Tuan | Ngày: | Loại File: PDF | Số trang:1

0
34
lượt xem
2
download

Chapter 23 Quick Reference

Mô tả tài liệu
  Download Vui lòng tải xuống để xem tài liệu đầy đủ

Chương 23 Quick tham khảo để làm này Tạo một kết nối đến một Sử dụng các nguồn dữ liệu cấu hình Wizard. Wizard sẽ nhắc bạn cho các chi tiết của kết nối để tạo và cơ sở dữ liệu đồ họa trong các đối tượng cơ sở dữ liệu để sử dụng. Visual Studio 2005.

Chủ đề:
Lưu

Nội dung Text: Chapter 23 Quick Reference

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