Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Boolean result from SQL Update for asp page

Status
Not open for further replies.

jimny

Technical User
Oct 18, 2002
52
0
0
US
I know that a sql functin should return a value of -1,0 or 1, but I have no been able to use it to validate whether a process has completed syuccessfully.

Example:
Code:
sql = "UPDATE tblNum t WHERE t.num = '"&num&"'"
verify = conn.execute(sql)
-- OR preferably--

is there a way to do it without using conn.execute:

Example:
Code:
rs.open = sql,conn,1,3
Thanks ahead of time

Seems like it should be easy, but then again, I don't have a regents diploma.
 
I believe you're talking about a return value. In order to make that happen you are going to have to first create a stored procedure in your database and tell it what to return under certain conditions. Then in your .asp page you will need to use the ADO command object to retrieve that output parameter. If I misunderstood, sorry.
 
If what i am talking about is a return value, then how do I retrieve said value?

CREATE Procedure InsertNum
@Num int(4)
As
Update tblNum set num = '@Num'
return @@Error
GO

????
 
OOPs sorry

coding two different thoughts in one post.

CREATE Procedure InsertNum
@Num int(4)
@RetVal
As
Update tblNum set num = '@Num'
return @@Error as RetVal
GO

-- OR --

CREATE Procedure InsertNum
@Num int(4)
As
Update tblNum set num = '@Num'
return @@Error
GO
 
The easy version:

Stored Proc
CREATE Procedure InsertNum
@Num int(4)
As
SET NOCOUNT ON
Update tblNum set num = '@Num'
SET NOCOUNT OFF
SELECT myERROR = @@Error

Then in your .asp page:
<%
set conn=server.createobject(&quot;ADODB.CONNECTION&quot;)
conn.open yourConnectionString
strSql=&quot;EXEC InsertNum @Num=&quot; & YourNumberVariable
set rs=Conn.execute(strSql)
myErrorCode=rs(0)
set rs=nothing
conn.close
set conn=nothing
If myErrorCode <> 0 then
response.write &quot;There was an error!&quot;
Else
response.write &quot;We had an error-free update!&quot;
End if
%>
 
thanks Veep,

haven't been able to get it running, but am in the right neighborhood
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top