Creating a Sqldatareader Objec
Số trang: 1
Loại file: pdf
Dung lượng: 11.00 KB
Lượt xem: 17
Lượt tải: 0
Xem trước 1 trang đầu tiên của tài liệu này:
Thông tin tài liệu:
Creating a SqlDataReader Object You can create a DataReader object only by calling the ExecuteReader() method of a Command object. Command objects were covered in the previous chapter.
Nội dung trích xuất từ tài liệu:
Creating a Sqldatareader ObjecCreating a SqlDataReader ObjectYou can create a DataReader object only by calling the ExecuteReader() method of aCommand object. Command objects were covered in the previous chapter. For example,the following code creates the required objects and executes a SELECT statement thatretrieves the top five rows from the Products table of the SQL Server Northwinddatabase, storing the returned rows in a SqlDataReader object:SqlConnection mySqlConnection = new SqlConnection( server=localhost;database=Northwind;uid=sa;pwd=sa );SqlCommand mySqlCommand = mySqlConnection.CreateCommand();mySqlCommand.CommandText = SELECT TOP 5 ProductID, ProductName, UnitPrice, + UnitsInStock, Discontinued + FROM Products + ORDER BY ProductID;mySqlConnection.Open();SqlDataReader productsSqlDataReader = mySqlCommand.ExecuteReader();Notice that the SqlDataReader object returned by the ExecuteReader() method is storedin the productsSqlDataReader object. Youll see how to use productsSqlDataReader inthe following section.
Nội dung trích xuất từ tài liệu:
Creating a Sqldatareader ObjecCreating a SqlDataReader ObjectYou can create a DataReader object only by calling the ExecuteReader() method of aCommand object. Command objects were covered in the previous chapter. For example,the following code creates the required objects and executes a SELECT statement thatretrieves the top five rows from the Products table of the SQL Server Northwinddatabase, storing the returned rows in a SqlDataReader object:SqlConnection mySqlConnection = new SqlConnection( server=localhost;database=Northwind;uid=sa;pwd=sa );SqlCommand mySqlCommand = mySqlConnection.CreateCommand();mySqlCommand.CommandText = SELECT TOP 5 ProductID, ProductName, UnitPrice, + UnitsInStock, Discontinued + FROM Products + ORDER BY ProductID;mySqlConnection.Open();SqlDataReader productsSqlDataReader = mySqlCommand.ExecuteReader();Notice that the SqlDataReader object returned by the ExecuteReader() method is storedin the productsSqlDataReader object. Youll see how to use productsSqlDataReader inthe following section.
Tìm kiếm theo từ khóa liên quan:
kĩ thuật lập trình công nghệ thông tin lập trình ngôn ngữ lập trình C Shark C# sybex - c.sharp database programming Creating a Sqldatareader ObjecTài liệu có liên quan:
-
52 trang 468 1 0
-
Top 10 mẹo 'đơn giản nhưng hữu ích' trong nhiếp ảnh
11 trang 367 0 0 -
96 trang 335 0 0
-
74 trang 329 0 0
-
Đồ án tốt nghiệp: Xây dựng ứng dụng di động android quản lý khách hàng cắt tóc
81 trang 321 0 0 -
Tài liệu dạy học môn Tin học trong chương trình đào tạo trình độ cao đẳng
348 trang 321 1 0 -
Giáo trình Lập trình hướng đối tượng: Phần 2
154 trang 317 0 0 -
Kỹ thuật lập trình trên Visual Basic 2005
148 trang 310 0 0 -
Báo cáo thực tập thực tế: Nghiên cứu và xây dựng website bằng Wordpress
24 trang 305 0 0 -
Tài liệu hướng dẫn sử dụng thư điện tử tài nguyên và môi trường
72 trang 303 0 0