Click to See Complete Forum and Search --> : Display Stored Procedure retuen Value


sr_aneesh
January 26th, 2005, 11:55 AM
Using Stored Procedure i want to insert record after checking if the record already exist in MS SQL 2000.
Now if the record already exist the record should not be inserted in to the SQL table otherwise it should be inserted
its fine with the SP i wrote but how do i display in browser if the record already exit.
For Eg : the display should be : The Tallyno : ABC already Exist

Stored Procedure is as follows :

CREATE PROCEDURE sp_con
@tno varchar(25),
@code varchar(25),
AS
if exists(select tno from tablename where tno=@tno and codecode=@code)
return 1
else
insert into tablename (tno,code) values(@tno,@code)
GO


The code in ASP is as follows

set Comm = Server.CreateObject("ADODB.Command")
Comm.ActiveConnection = Conn
Comm.CommandText = "sp_con"
Comm.CommandType = adCmdStoredProc
set paramtno = Comm.CreateParameter("@tno", adVarChar, adParamInput, 50, tno)
set paramcode = Comm.CreateParameter("@code", adVarChar, adParamInput, 50, code)

Comm.Parameters.Append(paramtno)
Comm.Parameters.Append(paramcode)

Comm.execute

Thanx in Advance