DayWalker Posted September 10, 2003 Posted September 10, 2003 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. Quote
Moderators Robby Posted September 10, 2003 Moderators Posted September 10, 2003 Place the Insert into an ELSE . Quote Visit...Bassic Software
JABE Posted September 11, 2003 Posted September 11, 2003 Add a parameter that has Direction = ParameterDirection.ReturnValue. After sp executes, check the Value of this parameter. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.