Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4557112
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T17:27:44+00:00 2026-05-21T17:27:44+00:00

I m creating new user registration moduleand for that i wrote following stored proc.

  • 0

I m creating new user registration moduleand for that i wrote following stored proc.

PROCEDURE [dbo].[addNewUser]
    -- Add the parameters for the stored procedure here
    @usertype VarChar(10),
    @useremail VarChar(70),
    @userpass VarChar(20),
    @fullname VarChar(70),
    @city VarChar(70),
    @state Int,
    @allowAlerts Bit,
    @allowLetter Bit,
    @aboutMe NVARCHAR(160)

As
BEGIN
    -- SET NOCOUNT ON added to prevent extra result sets from
    -- interfering with SELECT statements.
    SET NOCOUNT ON;


   if ((select count(user_info._id) from user_info where useremail like @useremail)  =  0)
    BEGIN
        Insert Into user_info
        (usertype,useremail,userpass,fullname,city,[state],allowAlerts,allowLetters,aboutMe)
           Values
           (
                @usertype,
                @useremail,
                @userpass ,
                @fullname,
                @city,
                @state,
                @allowAlerts,
                @allowLetter,
                @aboutMe
            )
        Select @@IDENTITY as NewID  
    END
    Else
    BEGIN
         Print '-1'         
    END 

And following is the simple ASP.net C# Code that I try to use

 public int registerNewUser(string usertype, string useremail, string userpass, string fullname, string city, string state, string allowAlerts, string allowLetter, string aboutMe)
        {
            con = new SqlConnection(connectionString);
            cmd = new SqlCommand();
            cmd.Connection = con;
            cmd.CommandType = CommandType.StoredProcedure;
            cmd.CommandText = "addBlogEntry";
            cmd.Parameters.Add("@usertype", SqlDbType.VarChar).Value = usertype;
            cmd.Parameters.Add("@useremail", SqlDbType.VarChar).Value = useremail;
            cmd.Parameters.Add("@userpass", SqlDbType.VarChar).Value = userpass;
            cmd.Parameters.Add("@fullname", SqlDbType.VarChar).Value = fullname;
            cmd.Parameters.Add("@city", SqlDbType.VarChar).Value = city;
            cmd.Parameters.Add("@state", SqlDbType.VarChar).Value = Convert.ToInt16(state);
            cmd.Parameters.Add("@allowAlerts", SqlDbType.VarChar).Value = Convert.ToInt16(allowAlerts);
            cmd.Parameters.Add("@allowLetter", SqlDbType.VarChar).Value = Convert.ToInt16(allowLetter);
            cmd.Parameters.Add("@aboutMe", SqlDbType.VarChar).Value = aboutMe;
            try
            {
                if (con.State != ConnectionState.Open)
                    con.Open();
                cmd.ExecuteNonQuery();
                con.Close();
                con.Dispose();

                // some code to be written here so that i can return userID(success) or -1(if that username is already registered)
                 return 0;
            }
            catch (Exception Ex)
            {
                con.Close();
                con.Dispose();

                return 0;
            }
        }

Through my C# code i want to return either auto generated userId which my stored procedures returns to me or if user alrady exists than i want to return -1

Please tell how to do this?

Thanks in advance 🙂

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-21T17:27:44+00:00Added an answer on May 21, 2026 at 5:27 pm

    Yes, you can use ExecuteScalar() and change

    Print '-1'
    

    into

    Select -1 as NewID
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have such view that handles user registration. After creating new user i want
We are creating a new site using ASP.NET membership provider for user registration and
So within my application is a form for creating a new user, with relevant
I'm creating a new WP theme and I would like to allow the user
After creating a new user john with: CREATE USER john PASSWORD 'test'; CREATE DATABASE
I am learning php on my own. I am creating a new user register
In my user registration routine, i have this code : @user = User.new(attribs) @user.build_inventory(:max_slots
Setting role when creating new user with ASP.net MVC I am looking at the
I'm using devise to do the new user registration. Right after a new user
I have problem creating new instance of excel 2007 using VBA (from Access 2002).

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.