i want fetch a single data named price from db to textbox but it yeilds 0
#My Stored procedure
GO
alter PROCEDURE [dbo].[spGetPrice]
@productId as int,
@categoryId as int,
@price as int output
AS
BEGIN
SELECT @price=price from product04 where product_id=@productId and category_id=@categoryId
END
GO
#My dll
conn.Open();
SqlCommand cmd = new SqlCommand("spGetPrice", conn);
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.AddWithValue("@productId", DbType.Int32).Value = productId;
cmd.Parameters.AddWithValue("@categoryId", DbType.Int32).Value = categoryId;
cmd.Parameters.Add("@price", SqlDbType.Int);
cmd.Parameters["@price"].Direction = ParameterDirection.Output;
price=Convert.ToInt32( cmd.ExecuteScalar());
#My bll int price;
try
{
price = dal.GetPrice(categoryId, productId);
return price;
}
catch
{
throw;
}
#code behind protected void btnGetDetails_Click(object sender, EventArgs e)
{
int productId=Convert.ToInt32(txtProductid.Text);
int categoryId=Convert.ToInt32(txtCategoryId.Text);
txtPrice.Text = bll.GetProductPrice(categoryId, productId).ToString();
}

Ramesh PalanivelRank #372 · 6.8K reputationPosted Oct 11, 2017, 9:00 PM EDT
sangeetha kRank #8,588 · 219 reputationPosted Oct 11, 2017, 9:21 PM EDT
Ramesh PalanivelRank #372 · 6.8K reputationPosted Oct 11, 2017, 9:29 PM EDT
sangeetha kRank #8,588 · 219 reputationPosted Oct 11, 2017, 10:11 PM EDT
Amit GuptaRank #190 · 12.8K reputationPosted Oct 11, 2017, 10:32 PM EDT
sangeetha kRank #8,588 · 219 reputationPosted Oct 11, 2017, 10:40 PM EDT
sangeetha kRank #8,588 · 219 reputationPosted Oct 11, 2017, 10:41 PM EDT
sangeetha kRank #8,588 · 219 reputationPosted Oct 11, 2017, 10:41 PM EDT
Ramesh PalanivelRank #372 · 6.8K reputationPosted Oct 11, 2017, 10:54 PM EDT
Ankit SharmaRank #141 · 16.1K reputationPosted Oct 12, 2017, 12:07 AM EDT
sangeetha kRank #8,588 · 219 reputationPosted Oct 12, 2017, 4:09 AM EDT