TAILIEUCHUNG - Developing Your First ADO.NET phần 2

Step 3: Set the CommandText Property of the SqlCommand Object You use SQL to work with the information stored in a database. SQL is an industry standard language supported by SQL Server, Access, and Oracle | Step 3 Set the CommandText Property of the SqlCommand Object You use SQL to work with the information stored in a database. SQL is an industry standard language supported by SQL Server Access and Oracle. You use the SQL SELECT statement for retrieving information from a database. You ll learn the basics of SQL in Chapter 3 Introduction to the Structured Query Language. Step 3 sets the CommandText property of mySqlCommand created in the previous step to a SELECT statement. This statement will retrieve the CustomerlD CompanyName ContactName and Address columns from the row in the Customers table whose CustomerlD is ALFKI SELECT CustomerlD CompanyName ContactName Address FROM Customers WHERE CustomerlD ALFKI Step 4 Open the SqlConnection Object Step 4 opens the database connection using the Open method of the SqlConnection object created in step 1 Once the connection to the database is open you can send commands to the database for execution. Step 5 Run the SELECT Statement You run the SELECT statement previously set in mySqlCommand by calling the ExecuteReader method. This method returns a SqlDataReader object that you then use to read the row data returned by the SELECT statement. Step 5 creates a SqlDataReader object and calls the ExecuteReader method of mySqlCommand object to run the SELECT statement SqlDataReader mySqlDataReader Step 6 Read the Row Using the SqlDataReader Object Step 6 reads the row in mySqlDataReader using the Read method Step 7 Display the Column Values from the SqlDataReader Object You can read the value for a column from mySqlDataReader by passing the name of the column in square brackets. For example mySqlDataReader CustomerID returns the value of the CustomerlD column. Step 7 displays the column values for the CustomerlD CompanyName ContactName and Address column values mySqlDataReader CustomerID mySqlDataReader CustomerID .

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.