codetoad.com
  ASP Shopping CartForum & BBS
  - all for $20 from CodeToad Plus!
  
  Home || ASP | ASP.Net | C++/C# | DHTML | HTML | Java | Javascript | Perl | VB | XML || CodeToad Plus! || Forums || RAM 
Search Site:
Search Forums:
  SQL stored procedure error  TheMatrix at 22:08 on Tuesday, May 02, 2006
 

I am trying to add a new stored procedure and I keep getting statement errors.
Can someone please take a look and this statement and tell me if they can see where is it failing?
The query analyzer is telling me that it is failing on the set command but to me this is correct.

CREATE PROCEDURE dbo.sp_Auth_GetCredentials

set ANSI_NULLS OFF
set QUOTED_IDENTIFIER ON
GO
ALTER PROCEDURE [dbo].[sp_Auth_GetCredentials]
@user varchar(50),
@pwd varchar(50)
AS
DECLARE @ReturnValue as int
SELECT @ReturnValue = COUNT(*) FROM auth WHERE (userName = @user AND userPwd = @pwd)

RETURN @ReturnValue

  Re: SQL stored procedure error  JBelthoff at 14:01 on Tuesday, May 09, 2006
 

You have several errors in your code.

1. You are trying to Alter a stored procedure before you creat it.

2. Your are using the RETURN statement incorrectly. WHat you want to to is use the RETURN Statement for bringing back the error status. It will do that automatically. Then you check if it is 0. If it is there were no SQL Errors if it is NOT 0 than SQL Server had an error which you can then handle in your Asp.Net code.

I think what you wnat to do to create this procedure is this...

CREATE PROCEDURE dbo.sp_Auth_GetCredentials

@user varchar(50),
@pwd varchar(50),
@ReturnValue int Output

AS

SELECT @ReturnValue = COUNT(*)
FROM auth
WHERE userName = @user
AND userPwd = @pwd

GO

ENjoy!

JB








CodeToad Experts

Can't find the answer?
Our Site experts are answering questions for free in the CodeToad forums
//








Recent Forum Threads
•  Date script issues
•  perl script help needed
•  onChange issue
•  perl remote execution
•  Chat application
•  How to send multiple perameters in SOAP request.
•  Java code for Insert picture on the table in spreadsheet
•  Re: Problem with concatenation
•  how to genrates the crystal report by sending a id at runtime


Recent Articles
ASP GetTempName
Decode and Encode UTF-8
ASP GetFile
ASP FolderExists
ASP FileExists
ASP OpenTextFile
ASP FilesystemObject
ASP CreateFolder
ASP CreateTextFile
Javascript Get Selected Text


© Copyright codetoad.com 2001-2007