假设我的表由两列ID
和Name
.
并假设我的存储过程在 vb.net 上工作,将行插入数据库。
但是当点击添加按钮时,我的系统需要检查ID
数据库中是否已经存在输入的文本框。
CREATE PROCEDURE AddOfficeEquipmentProfile
(
@OE_ID varchar(11),
@OE_Category char(3) =NULL,
@OE_SubCategory char(3)= NULL,
@OE_Name varchar(35)=NULL,
@OE_User varchar(35)=NULL,
@OE_Brand varchar(15)=NULL,
@OE_Model varchar(35)=NULL,
@OE_Specs varchar(1000)=NULL,
@OE_SerialNo varchar(35)=NULL,
@OE_PropertyNo varchar(35)=NULL,
@OE_MacAddress varchar(100)=NULL,
@OE_Static_IP varchar(15)=NULL,
@OE_Vendor varchar(35)=NULL,
@OE_PurchaseDate smalldatetime,
@OE_WarrantyInclusiveYear int=NULL,
@OE_WarrantyStatus char(2)= NULL,
@OE_Status varchar(15)=NULL,
@OE_Dept_Code char(3)= NULL,
@OE_Location_Code char(8)= NULL,
@OE_Remarks varchar(1000)= NULL
)
AS
INSERT INTO tblOfficeEquipmentProfile (OE_ID, OE_Category, OE_SubCategory, OE_Name, OE_User, OE_Brand, OE_Model, OE_Specs, OE_SerialNo,
OE_PropertyNo, OE_MacAddress, OE_Static_IP, OE_Vendor, OE_PurchaseDate, OE_WarrantyInclusiveYear, OE_WarrantyStatus, OE_Status, OE_Dept_Code,
OE_Location_Code, OE_Remarks )
VALUES (@OE_ID, @OE_Category, @OE_SubCategory, @OE_Name, @OE_User, @OE_Brand, @OE_Model,
@OE_Specs, @OE_SerialNo, @OE_PropertyNo, @OE_MacAddress, @OE_Static_IP, @OE_Vendor, @OE_PurchaseDate, @OE_WarrantyInclusiveYear, @OE_WarrantyStatus,
@OE_Status, @OE_Dept_Code, @OE_Location_Code, @OE_Remarks)
GO