tailieunhanh - Microsoft ADO .NET 4 Step by Step - p 20
Mã này truy cập các bản ghi trong tập thứ hai của kết quả, các câu lệnh SELECT cho bảng OrderEntry, thông qua phương pháp gọi NextResult. 5. Khởi động chương trình. Về hình thức quản lý khách hàng, hãy chọn một khách hàng từ danh sách các khách hàng và sau đó nhấp vào Xem đơn đặt hàng. | 166 Microsoft 4 Step by Step 4. Just after the Read the next set which contains the orders comment add the following code Do While True oneOrder New OrderInfo CLng customerReader ID CDate customerReader OrderDate CDec customerReader Total oneOrder Loop This code accesses the records in the second set of results the SELECT statement for the OrderEntry table via the NextResult method call. 5. Run the program. On the Customer Management form select a customer from the list of customers and then click View Orders. When the View Orders form appears it includes content from both SELECT statements returned by the stored procedure. Summary This chapter discussed parameters which are data value objects that help ensure the accuracy and safety of the data being sent to and returned from external data sources. Parameterized queries use special SQL statements that include placeholders for each parameter. Each SqlParameter instance defines the name of the parameter its data type and its value. Parameters work with either standard SQL commands or with stored procedures. When using them with stored procedures you can create both input and output stored procedures supporting two-way communications with these custom database functions. Chapter 10 Adding Standards to Queries 167 Chapter 10 Quick Reference To Do This Create a parameterized query for SQL Server Create a SQL query string that includes -prefixed placeholders. Create a SqlCommand instance. Assign the SQL query to the SqlCommand object s CommandText property. Create SqlParameter objects one for each placeholder in the query and add them to the command object s Parameters collection. Set the property. Call one of the command object s Execute methods. Create a parameterized query for an OLE DB data source Create a SQL query string that includes question marks for placeholders. .
đang nạp các trang xem trước