RE-Drop Down List Error
-
HI, I am getting the following Errors,while inserting drop down list values in sql server database ERROR: Server Error in '/Online_Book_Shopping' Application. Procedure or function 'spRegisteruser' expects parameter '@countryname', which was not supplied. 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: Procedure or function 'spRegisteruser' expects parameter '@countryname', which was not supplied. Source Error: Line 60: cmd.Parameters.Add(password); Line 61: con.Open(); Line 62: int i= cmd.ExecuteNonQuery(); Line 63: con.Close(); Line 64: } Source File: e:\Vijaya\Online_Book_Shopping\SignUp.aspx.cs Line: 62 How to solve this???Please Help??? This is my code: aspx.cs:- protected void btnn_Click(object sender, EventArgs e) { string constr = ConfigurationManager.ConnectionStrings["CS"].ConnectionString; using (SqlConnection con = new SqlConnection(constr)) { SqlCommand cmd = new SqlCommand("spRegisteruser", con); cmd.CommandType = CommandType.StoredProcedure; SqlParameter name = new SqlParameter("@name", txtusername.Text); SqlParameter mobile = new SqlParameter("@mobile", txtmobilenumber.Text); SqlParameter password = new SqlParameter("@password", txtpassword.Text); SqlParameter dropdown = new SqlParameter("@country",DropDownList1.SelectedItem.Value); cmd.Parameters.Add(name); cmd.Parameters.Add(dropdown); cmd.Parameters.Add(mobile); cmd.Parameters.Add(password); con.Open(); int i= cmd.ExecuteNonQuery(); con.Close(); } Sql table:- Create Table dbo.RegisteredUsers ( ID int identity Primary Key, Name nvarchar(20), Country_Name nvarchar(30), Mobile_No bigint, [Password] nvarchar(20) ) Go This is storedprocedure:- Alter Proc spRegisteruser @Name nvarchar(20), @countryname nvarchar(30), @mobile bigint,
-
HI, I am getting the following Errors,while inserting drop down list values in sql server database ERROR: Server Error in '/Online_Book_Shopping' Application. Procedure or function 'spRegisteruser' expects parameter '@countryname', which was not supplied. 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: Procedure or function 'spRegisteruser' expects parameter '@countryname', which was not supplied. Source Error: Line 60: cmd.Parameters.Add(password); Line 61: con.Open(); Line 62: int i= cmd.ExecuteNonQuery(); Line 63: con.Close(); Line 64: } Source File: e:\Vijaya\Online_Book_Shopping\SignUp.aspx.cs Line: 62 How to solve this???Please Help??? This is my code: aspx.cs:- protected void btnn_Click(object sender, EventArgs e) { string constr = ConfigurationManager.ConnectionStrings["CS"].ConnectionString; using (SqlConnection con = new SqlConnection(constr)) { SqlCommand cmd = new SqlCommand("spRegisteruser", con); cmd.CommandType = CommandType.StoredProcedure; SqlParameter name = new SqlParameter("@name", txtusername.Text); SqlParameter mobile = new SqlParameter("@mobile", txtmobilenumber.Text); SqlParameter password = new SqlParameter("@password", txtpassword.Text); SqlParameter dropdown = new SqlParameter("@country",DropDownList1.SelectedItem.Value); cmd.Parameters.Add(name); cmd.Parameters.Add(dropdown); cmd.Parameters.Add(mobile); cmd.Parameters.Add(password); con.Open(); int i= cmd.ExecuteNonQuery(); con.Close(); } Sql table:- Create Table dbo.RegisteredUsers ( ID int identity Primary Key, Name nvarchar(20), Country_Name nvarchar(30), Mobile_No bigint, [Password] nvarchar(20) ) Go This is storedprocedure:- Alter Proc spRegisteruser @Name nvarchar(20), @countryname nvarchar(30), @mobile bigint,
The error:
Procedure or function 'spRegisteruser' expects parameter '@countryname', which was not supplied.
Your code:
SqlParameter dropdown = new SqlParameter("@country",DropDownList1.SelectedItem.Value);
Did you see it now? You have set a parameter named
@country
instead of@countryname
. -
HI, I am getting the following Errors,while inserting drop down list values in sql server database ERROR: Server Error in '/Online_Book_Shopping' Application. Procedure or function 'spRegisteruser' expects parameter '@countryname', which was not supplied. 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: Procedure or function 'spRegisteruser' expects parameter '@countryname', which was not supplied. Source Error: Line 60: cmd.Parameters.Add(password); Line 61: con.Open(); Line 62: int i= cmd.ExecuteNonQuery(); Line 63: con.Close(); Line 64: } Source File: e:\Vijaya\Online_Book_Shopping\SignUp.aspx.cs Line: 62 How to solve this???Please Help??? This is my code: aspx.cs:- protected void btnn_Click(object sender, EventArgs e) { string constr = ConfigurationManager.ConnectionStrings["CS"].ConnectionString; using (SqlConnection con = new SqlConnection(constr)) { SqlCommand cmd = new SqlCommand("spRegisteruser", con); cmd.CommandType = CommandType.StoredProcedure; SqlParameter name = new SqlParameter("@name", txtusername.Text); SqlParameter mobile = new SqlParameter("@mobile", txtmobilenumber.Text); SqlParameter password = new SqlParameter("@password", txtpassword.Text); SqlParameter dropdown = new SqlParameter("@country",DropDownList1.SelectedItem.Value); cmd.Parameters.Add(name); cmd.Parameters.Add(dropdown); cmd.Parameters.Add(mobile); cmd.Parameters.Add(password); con.Open(); int i= cmd.ExecuteNonQuery(); con.Close(); } Sql table:- Create Table dbo.RegisteredUsers ( ID int identity Primary Key, Name nvarchar(20), Country_Name nvarchar(30), Mobile_No bigint, [Password] nvarchar(20) ) Go This is storedprocedure:- Alter Proc spRegisteruser @Name nvarchar(20), @countryname nvarchar(30), @mobile bigint,
It looks like you have misnamed a parameter. I guess that
Member 11161625 wrote:
SqlParameter dropdown = new SqlParameter("@country",DropDownList1.SelectedItem.Value);
should be
Member 11161625 wrote:
SqlParameter dropdown = new SqlParameter("@countryname",DropDownList1.SelectedItem.Value);
so that the parameter name in the Parameters collection matches the parameter name in the Stored Procedure.
-
The error:
Procedure or function 'spRegisteruser' expects parameter '@countryname', which was not supplied.
Your code:
SqlParameter dropdown = new SqlParameter("@country",DropDownList1.SelectedItem.Value);
Did you see it now? You have set a parameter named
@country
instead of@countryname
.Incredible when the error message tells you exactly what the problem is. :-\ :thumbsup:
There are two kinds of people in the world: those who can extrapolate from incomplete data. There are only 10 types of people in the world, those who understand binary and those who don't.