Đang chuẩn bị liên kết để tải về tài liệu:
Microsoft ADO .NET 4 Step by Step - p 19

Không đóng trình duyệt đến khi xuất hiện nút TẢI XUỐNG

Lớp SqlCommand bao gồm một bộ sưu tập các tham số mà bạn thêm vào các giá trị thay thế cụ thể cho từng giữ chỗ. Bạn quấn lên từng tham số trong một thể hiện của SqlParameter, thiết lập thuộc tính của nó khi cần thiết, và thêm vào bộ sưu tập SqlCommand.Parameters. | 156 Microsoft ADO.NET 4 Step by Step As with nonparameterized queries this enhanced statement gets wrapped up in a SqlCommand object C string sqlText @ UPDATE Employee SET Salary @NewSalary WHERE ID @EmployeeID SqlCommand salaryUpdate new SqlCommand sqlText linkToDB Visual Basic Dim sqlText As String UPDATE Employee SET Salary @NewSalary WHERE ID @EmployeeID Dim salaryUpdate New SqlCommand sqlText linkToDB The SqlCommand class includes a Parameters collection to which you add the specific replacement values for each placeholder. You wrap up each parameter in an instance of SqlParameter setting its properties as needed and adding it to the SqlCommand.Parameters collection. When you execute the command ADO.NET passes both the placeholder-laden SQL text and the parameter collection to the database for evaluation. Each parameter includes the elements you would expect the parameter name which must match a placeholder name in the SQL statement the data type along with any data typespecific settings such as the length of string parameters the actual data content to be included in the processed command and a few other generic settings. To add a parameter to a command create a SqlParameter instance and add it to the SqlCommand object. C SqlParameter paramValue new SqlParameter @NewSalary SqlDbType.Money paramValue.Value 50000m salaryUpdate.Parameters.Add paramValue paramValue new SqlParameter @EmployeeID SqlDbType.BigInt paramValue.Value 25L salaryUpdate.Parameters.Add paramValue Visual Basic Dim paramValue As New SqlParameter @NewSalary SqlDbType.Money paramValue.Value 50000@ salaryUpdate.Parameters.Add paramValue paramValue New SqlParameter @EmployeeID SqlDbType.BigInt paramValue.Value 25 salaryUpdate.Parameters.Add paramValue Chapter 10 Adding Standards to Queries 157 SqlParameter includes lots of constructor options for setting the data type of the passed data plus other settings. Or you can go the traditional route and update the object s individual properties directly

Đã 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.