TAILIEUCHUNG - Using a DataGrid Control to Access a Database

Using a DataGrid Control to Access a Database In this section, you'll learn how to use a DataGrid control to access the rows | Using a DataGrid Control to Access a Database In this section you ll learn how to use a DataGrid control to access the rows in a database table. Follow these steps to create a DataGrid using VS .NET 1. First select File New Project. In the New Project dialog box select Windows Application and enter DataGridWindowsApplication in the Name field. 2. Click OK to continue. Your new project will contain a blank form. 3. Add a DataGrid control to the form by selecting View Toolbox selecting a DataGrid and dragging it to your form. Figure shows a form with a DataGrid. Make your DataGrid almost as big as your form by dragging the corners of your DataGrid out to the end of your form. Figure Form with a DataGrid Next you ll add a SqlConnection object and a SqlDataAdapter object to your form. Note You use a SqlConnection object to connect to a SQL Server database and a SqlDataAdapter object to move rows between SQL Server and a DataSet object. You ll learn the details on how to pull rows from the database into a DataSet in Chapter 10 and how to push changes made in a DataSet to the database in Chapter 11. You can drag a table from a SQL Server database onto your form and have the SqlConnection and SqlDataAdapter objects created in one step. You use Server Explorer for this. With databases that do not show up in Server Explorer your choices are limited. You can use the controls in Data category of the Toolbox to drag each item to your form and then set properties for each data object with the Properties window. Note To open Server Explorer select View Server Explorer or press Cntl Alt S. To add a SqlConnection and SqlDataAdapter object to your form perform the following steps 1. Open Server Explorer. 2. Open the connection to your SQL Server Northwind database or create a new connection if necessary by right-clicking on the Data Connections node and selecting Add Connection and entering the sa username and password for your Northwind database you might need to get the .

TAILIEUCHUNG - Chia sẻ tài liệu không giới hạn
Địa chỉ : 444 Hoang Hoa Tham, Hanoi, Viet Nam
Website : tailieuchung.com
Email : tailieuchung20@gmail.com
Tailieuchung.com là thư viện tài liệu trực tuyến, nơi chia sẽ trao đổi hàng triệu tài liệu như luận văn đồ án, sách, giáo trình, đề thi.
Chúng tôi không chịu trách nhiệm liên quan đến các vấn đề bản quyền nội dung tài liệu được thành viên tự nguyện đăng tải lên, nếu phát hiện thấy tài liệu xấu hoặc tài liệu có bản quyền xin hãy email cho chúng tôi.
Đã phát hiện trình chặn quảng cáo AdBlock
Trang web này phụ thuộc vào doanh thu từ số lần hiển thị quảng cáo để tồn tại. Vui lòng tắt trình chặn quảng cáo của bạn hoặc tạm dừng tính năng chặn quảng cáo cho trang web này.