TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
sangeetha k
NA
207
51.3k
sql exception occurs checked various times but it shows
Oct 24 2017 10:07 AM
#my Dal
public void UpdateProductDetail(EntityClass en)
{
SqlConnection conn = new SqlConnection(constring);
try
{
conn.Open();
SqlCommand cmd = new SqlCommand("spUpdateProductDetails", conn);
cmd.Parameters.AddWithValue("@prodName", DbType.String).Value = en.ProductName;
cmd.Parameters.AddWithValue("@productId", DbType.Int32).Value = en.ProductId;
cmd.Parameters.AddWithValue("@productDesc", DbType.String).Value = en.ProductDescription;
cmd.Parameters.AddWithValue("@categoryId", DbType.Int32).Value = en.CategoryId;
cmd.Parameters.AddWithValue("@price", DbType.Int32).Value =en.Price;
cmd.Parameters.AddWithValue("@availability", DbType.String).Value = en.Availability;
cmd.ExecuteNonQuery();
}
catch(Exception)
{
throw new Exception("");
}
}
#code behind
protected void grdView1ProductUpdate(object sender, GridViewUpdateEventArgs e)
{
TextBox txtProductName = grdView1.Rows[e.RowIndex].FindControl("txtProductName") as TextBox;
TextBox txtProductId = grdView1.Rows[e.RowIndex].FindControl("txtProductId") as TextBox;
TextBox txtProductDesc = grdView1.Rows[e.RowIndex].FindControl("txtProductDesc") as TextBox;
TextBox txtCategoryId = grdView1.Rows[e.RowIndex].FindControl("txtCategoryId") as TextBox;
TextBox txtPrice = grdView1.Rows[e.RowIndex].FindControl("txtPrice") as TextBox;
TextBox txtAvailability = grdView1.Rows[e.RowIndex].FindControl("txtAvailability") as TextBox;
EntityClass en=new EntityClass(txtProductName.Text,Convert.ToInt32(txtProductId.Text),txtProductDesc.Text,Convert.ToInt32(txtCategoryId.Text),Convert.ToInt32(txtPrice.Text),txtAvailability.Text);
bll.UpdateProductDetail(en);
grdView1.EditIndex=-1;
ShowGrid();
}
#my stored procedure
Go
alter procedure[dbo].[spUpdateProductDetails]
@prodName as nvarchar(50),
@productId as int,
@productDesc as nvarchar(50),
@categoryId as int,
@price as int,
@availability as nvarchar(50)
as
begin
update ProductDetail set ProductName=@prodName,ProductDescription=@productDesc,CategoryId=@categoryId,Price=@price,Availability=@availability where ProductId=@productId
end
go
#exception im getting is
Procedure or function 'spUpdateProductDetails' expects parameter '@prodName', which was not supplied.
# correct me where iam wrong
Reply
Answers (
2
)
Building A .NET Core 2.0 Class Library
How to access file uplod cntrl in any other class