Tech
Forums
Jobs
Books
Events
Videos
Conference
Annual Conference
Bcrypt
Ai Conference
Live
More
Interviews
Certification
Training
Career
Members
News
Blogs
Contribute
An Article
A Blog
A Video
An Ebook
An Interview Question
Register
Login
11
Answers
Fetchhing price from db to textbox
Ask a question
Ask a question
Upload Source Code:
Select only zip and rar file.
sangeetha k
6y
258
1
Reply
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();
}
Post
Reset
Cancel
Answers (
11
)
Next Recommended Forum
How to reduce overlapping text in pdf using rotativa in MVC
how to display calendar in web grid using mvc