Re: "Must declare the scalar variable @Nickname"...

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance

From: Scott G. (noemail_at_this-is-extra-hotmail.com)
Date: 07/09/04


Date: Fri, 9 Jul 2004 15:48:44 -0400

 I'm not exactly sure what you are asking; are you saying that your sproc is always returning -1? If you think the SELECT * FROM users... should be "failing" try to return a count or debug the sproc. You could also run put some SQL PRINT statements in you sproc and run it from QueryAnalyzer if you need to troubleshoot.

Scott

  "Jiggaz" <anonymous@discussions.microsoft.com> wrote in message news:2a92101c465da$bbec7bd0$a301280a@phx.gbl...
  i have done that :
  ________________
  IF EXISTS (SELECT * FROM users WHERE nickname = @Nickname)
  BEGIN
      -- the user is there
      RETURN -1
  END
  ELSE BEGIN
      insert into users values (@Nickname , @Password ,
  @Email , @Date, @Name, @Lastname, @Sexe,
  @Titre, @Adress, @Birthday, @Phonetel, @Mobilephone,
  @Website, 50, '', '', '', '', @MailsAllowed)
  RETURN 1
  END
  ___________________

  But, always return me -1 but, it's good: if user is
  already in the table, sql doesn't add him and if not
  exists, add! But always return me in msg box -1?
  How to get if it hsn't been added to show a message : good
  or error if already in base?

  Thanks. Regards.

>-----Original Message-----
>You might have better luck with this question in the
  sqlserver groups (microsoft.public.sqlserver.programming).
  In the meantime, why not let Transact-SQL do some of the
  work for you
>
>IF EXISTS (SELECT * FROM users WHERE nickname = @Nickname)
  BEGIN
> -- the user is there
>END
>ELSE BEGIN
> -- the user is not there
>END
>
>Scott
> "Jiggaz" <anonymous@discussions.microsoft.com> wrote in
  message news:2a52b01c465a7$a1ef12c0$a301280a@phx.gbl...
> Hi,
>
> Look my stored procedure :
> __________________
> ALTER PROCEDURE dbo.CreateAccount
>
> @Nickname varchar(30),
> @Password varchar(15),
> @Email varchar(50),
> @Date datetime,
> @Name varchar(50),
> @Lastname varchar(50),
> @Sexe varchar(2),
> @Titre varchar(15),
> @Adress varchar(255),
> @Birthday varchar(50),
> @Phonetel varchar(50),
> @Mobilephone varchar(50),
> @Website varchar(255),
> @MailsAllowed varchar(2)
>
> AS
>
> DECLARE @insertstring nchar(4000)
> DECLARE @checkforexistingrecord VARCHAR(60)
> DECLARE @add VARCHAR(2000)
> DECLARE @usernick VARCHAR(30)
>
> SET @usernick = @Nickname
>
> SET @insertstring = 'DECLARE @checkforexistingrecord
> VARCHAR(60)
> SELECT nickname FROM users WHERE nickname = '''
> + @usernick + ''''
> EXEC(@insertstring)
> SELECT @checkforexistingrecord = @@ROWCOUNT
> __________________
>
> Why i get this error?
> I just want to verify if the username already exists..
>
> Thanks. Regards.



Relevant Pages

  • Re: date useage in vb expression
    ... > a WHERE clause rather than a named filter or query. ... >> End Sub ... >> Best regards ... >> Scott B ...
    (microsoft.public.access.formscoding)
  • Re: Stored Procedure Best Practice
    ... Scott, thanks a lot. ... on the sql group, and am anxious to check it out. ... > performance, especially with optional params. ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: searching on more than one field in VB
    ... However, to simulate an SQL ... >> Regards, ... >> Tom Ogilvy ... >>> sheet into one of seven textboxes and search for information in ...
    (microsoft.public.excel.programming)
  • Re: GROUP BY...
    ... > Dominique Javet wrote: ... >> Regards, Dom ... > These two are completely unrelated SQL commands. ... > query, which you didn't. ...
    (comp.lang.php)
  • Re: Multilingual versions of SQL Express 2005 available ? Where ?
    ... So we haven't any further better means without the localized SQL express ... Microsoft Online Support ... | Regards, Keith ... |> we may consider provide localized error message according to the error ...
    (microsoft.public.sqlserver.setup)