I am executing a stored procedure from VB.Net the SP looks something like this:
CREATE PROC Name
@MachineID char(10),
@DateCreated smalldatetime,
@CreatedBy Varchar(20)
AS
IF EXISTS(SELECT Machine_ID FROM Table WHERE Machine_ID=@MachineID)
BEGIN
RAISERROR(50007,10,1)
RETURN -2
END
INSERT dbo.Table
(Machine_ID, DateCreated, CreatedBy)
VALUES
(@MachineID, @DateCreated, @CreatedBy)
------
How would i go about getting the returned value of -2 in VB.
I can Insert no problem but if the MachineID already exists in the db it completes it as normal and i cannot show the user that the record already exists and that it did not complete they need to change the machineID before it will enter the data.
CREATE PROC Name
@MachineID char(10),
@DateCreated smalldatetime,
@CreatedBy Varchar(20)
AS
IF EXISTS(SELECT Machine_ID FROM Table WHERE Machine_ID=@MachineID)
BEGIN
RAISERROR(50007,10,1)
RETURN -2
END
INSERT dbo.Table
(Machine_ID, DateCreated, CreatedBy)
VALUES
(@MachineID, @DateCreated, @CreatedBy)
------
How would i go about getting the returned value of -2 in VB.
I can Insert no problem but if the MachineID already exists in the db it completes it as normal and i cannot show the user that the record already exists and that it did not complete they need to change the machineID before it will enter the data.