Ly Huelar

Ly Huelar

  • NA
  • 15
  • 8.4k

Stored procedure error-

Oct 14 2016 12:15 PM
Hello! I need some help in my Storage procedure code, when I want to save it and this error  pops up. 
 
So when I run my program and click the register button it shows this error,

Server Error in '/' Application.

Could not find stored procedure 'Insert_User'.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Data.SqlClient.SqlException: Could not find stored procedure 'Insert_User'.

Source Error:

Line 62:                 cmd.Connection = con; Line 63:                 con.Open(); Line 64:                 userId = Convert.ToInt32(cmd.ExecuteScalar()); Line 65:                 con.Close(); Line 66:             }
 
(This is my stored procedure code) 
ALTER PROCEDURE [dbo].[Insert_User]
@Firstname VARCHAR(50)
,@Middlename VARCHAR(50)
,@Lastname VARCHAR(50)
,@Suffix VARCHAR(50)
,@Nickname VARCHAR(50)
,@Username VARCHAR(50)
,@Password VARCHAR(50)
,@Gender VARCHAR(50)
,@Civilstatus VARCHAR(50)
,@Month VARCHAR(50)
,@Day VARCHAR(50)
,@Year VARCHAR(50)
,@Birthplace VARCHAR(50)
,@Citizenship VARCHAR(50)
,@Address VARCHAR(50)
,@Mobilenumber VARCHAR(50)
,@Emailaddress VARCHAR(50)
,@Fathername VARCHAR(50)
,@Fatherbplace VARCHAR(50)
,@Mothername VARCHAR(50)
,@Motherbplace VARCHAR(50)
,@Educattainment VARCHAR(50)
,@Occupation VARCHAR(50)
,@Religion VARCHAR(50)
,@Height VARCHAR(50)
,@Weight VARCHAR(50)
AS
BEGIN
SET NOCOUNT ON;
IF EXISTS(SELECT UserId FROM registration WHERE Username = @Username)
BEGIN
SELECT -1 -- Username exists.
END
ELSE IF EXISTS(SELECT UserId FROM registration WHERE Emailaddress = @Emailaddress)
BEGIN
SELECT -2 -- Email exists.
END
ELSE
BEGIN
INSERT INTO registration
([Firstname]
,[Middlename]
,[Lastname]
,[Suffix]
,[Nickname]
,[Username]
,[Password]
,[Gender]
,[Civilstatus]
,[Month]
,[Day]
,[Year]
,[Birthplace]
,[Citizenship]
,[Address]
,[Mobilenumber]
,[Emailaddress]
,[Fathername]
,[Fatherbplace]
,[Mothername]
,[Motherbplace]
,[Educattainment]
,[Occupation]
,[Religion]
,[Height]
,[Weight])
VALUES
(@Firstname
,@Middlename
,@Lastname
,@Suffix
,@Nickname
,@Username
,@Password
,@Gender
,@Civilstatus
,@Month
,@Day
,@Year
,@Birthplace
,@Citizenship
,@Address
,@Mobilenumber
,@Emailaddress
,@Fathername
,@Fatherbplace
,@Mothername
,@Motherbplace
,@Educattainment
,@Occupation
,@Religion
,@Height
,@Weight())
SELECT SCOPE_IDENTITY() -- UserId
END
END

Answers (4)