Kinh doanh - Marketing
Kinh tế quản lý
Biểu mẫu - Văn bản
Tài chính - Ngân hàng
Công nghệ thông tin
Tiếng anh ngoại ngữ
Kĩ thuật công nghệ
Khoa học tự nhiên
Khoa học xã hội
Văn hóa nghệ thuật
Sức khỏe - Y tế
Văn bản luật
Nông Lâm Ngư
Kỹ năng mềm
Luận văn - Báo cáo
Giải trí - Thư giãn
Tài liệu phổ thông
Văn mẫu
Giới thiệu
Đăng ký
Đăng nhập
Tìm
Danh mục
Kinh doanh - Marketing
Kinh tế quản lý
Biểu mẫu - Văn bản
Tài chính - Ngân hàng
Công nghệ thông tin
Tiếng anh ngoại ngữ
Kĩ thuật công nghệ
Khoa học tự nhiên
Khoa học xã hội
Văn hóa nghệ thuật
Y tế sức khỏe
Văn bản luật
Nông lâm ngư
Kĩ năng mềm
Luận văn - Báo cáo
Giải trí - Thư giãn
Tài liệu phổ thông
Văn mẫu
Thông tin
Điều khoản sử dụng
Quy định bảo mật
Quy chế hoạt động
Chính sách bản quyền
Giới thiệu
Đăng ký
Đăng nhập
0
Trang chủ
Công Nghệ Thông Tin
Kỹ thuật lập trình
ASP.NET 4 Unleased - p 90
Đang chuẩn bị liên kết để tải về tài liệu:
ASP.NET 4 Unleased - p 90
Anh Duy
214
10
pdf
Đang chuẩn bị nút TẢI XUỐNG, xin hãy chờ
Tải xuống
Bản tuyên bố đầu tiên tạo ra một đối tượng SqlCommand đại diện cho một lệnh SQL INSERT. lệnh này bao gồm một tham số có tên là @ đề. Các báo cáo thứ hai cho biết thêm một SqlParameter vào bộ sưu tập các tham số của đối tượng SqlCommand. Các AddWithValue () phương pháp cho phép bạn thêm một tham số với một tên nào đó và giá trị. | 864 CHAPTER 19 Building Data Access Components with ADO.NET The first statement creates a SqlCommand object that represents a SQL INSERT command. The command includes a parameter named @Title. The second statement adds a SqlParameter to the SqlCommand object s Parameters collection. The AddWithValue method enables you to add a parameter with a certain name and value. In this case the method supplies the value for the @Title parameter. When you execute the SqlCommand the following command is sent to Microsoft SQL Server exec sp_executesql N INSERT Titles Title VALUES @Title N @Title nvarchar 17 @Title N ASP.NET 4.0 Unleashed The SqlCommand object calls the sp_executesql stored procedure when it executes a command. In this case it passes the type size and value of the @Title parameter to the sp_executesql stored procedure. When you use AddWithValue the SqlCommand object infers the type and size of the parameter for you. The method assumes that string values are SQL NVarChar values integer values are SQL Int values decimal values are SQL decimal values and so on. As an alternative to using the AddWithValue method you can create a SqlParameter explicitly and add the SqlParameter to a SqlCommand object s Parameters collection. The advantage of creating a parameter explicitly is that you can specify parameter properties explicitly such as its name type size precision scale and direction. For example the following code creates a parameter named @Title with a particular data type size and value SqlCommand cmd new SqlCommand INSERT Titles Title VALUES @Title con SqlParameter paramTitle new SqlParameter paramTitle.ParameterName @Title paramTitle.SqlDbType SqlDbType.NVarChar paramTitle.Size 50 paramTitle.Value ASP.NET 4.0 Unleashed cmd.Parameters.Add paramTitle If this seems like a lot of code to do something simple you can use one of the overloads of the Add method to create a new SqlParameter like this SqlCommand cmd new SqlCommand INSERT Test Title VALUES @Title con .
TÀI LIỆU LIÊN QUAN
crossorigin="anonymous">
Đã 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.