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
Fetchhing price from db to textbox
Oct 12 2017 12:50 AM
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();
}
Reply
Answers (
11
)
How to reduce overlapping text in pdf using rotativa in MVC
how to display calendar in web grid using mvc