I have created a Stored procedure to Insert my data into the table, but I am getting error as
Procedure or function 'AddUserDetails' expects parameter '@UserId', which was not supplied.
Here is my SP
CREATE PROCEDURE AddUserDetails
@UserId nvarchar(55),
@UserPassword nvarchar(100),
@ConfirmPass nvarchar(100),
@Mobile int,
@Email nvarchar(100),
@BirthDate nvarchar(100)
AS
BEGIN
SET NOCOUNT ON;
Insert into RegisterUser(UserId,UserPassword,ConfirmPass, Mobile, Email,BirthDate)Values (@UserId, @UserPassword, @ConfirmPass, @Mobile, @Email,@BirthDate)
END
GO
Also here is my C# code.
protected void btnSubmit_Click(object sender, EventArgs e)
{
try
{
SqlCommand cmd = new SqlCommand();
cmd.Parameters.Add("@UserId", SqlDbType.NVarChar).Value = txtUserId.Text;
cmd.Parameters.Add("@UserPassword", SqlDbType.NVarChar).Value = txtPassword.Text;
cmd.Parameters.Add("@ConfirmPassword", SqlDbType.NVarChar).Value = txtConfirmPassword.Text;
cmd.Parameters.Add("@Mobile", SqlDbType.Int).Value = txtMobile.Text;
cmd.Parameters.Add("@Email", SqlDbType.NVarChar).Value = txtEmail.Text;
cmd.Parameters.Add("@BirthDate", SqlDbType.NVarChar).Value = txtBirth.Text;
cmd = new SqlCommand("AddUserDetails", con);
cmd.CommandType = CommandType.StoredProcedure;
con.Open();
cmd.ExecuteNonQuery();
Response.Redirect("http://www.google.com");
con.Close();
}
catch (Exception ex)
{
throw ex;
}
}
Kindly suggest what is the mistake here