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
Sousa Pambo
NA
92
24.2k
Error formating number
Sep 6 2015 6:50 PM
Hi friends, I'm getting a error when I format number ( e.g 452 to 452.00), please see my code below
public double getValorPropinaPagoMesYear(string id_c, int mes, int year)
{
string sql = "select sum(valPago) as n from estudanteMensalidade where ficha_id='" + id_c + "' and ano=" + (year - 2000).ToString() + " and mes=" + mes.ToString();
using (SqlConnection cn = new SqlConnection(con.stringConexaoRH()))
{
try
{
cn.Open();
using (SqlCommand cm = new SqlCommand(sql, cn))
{
using (SqlDataReader rd = cm.ExecuteReader())
{
if (rd.Read())
{
try
{
return Convert.ToDouble(string.Format("{0:0.00}", rd[0]))
;
}
catch (Exception ex)
{
return 0;
}
}
else
{
return 0;
}
}
}
}
catch (Exception ex)
{
MessageBox.Show(ex.ToString());
}
}
}
Please Help!
Reply
Answers (
3
)
What is difference between library vs framework ?
How to run web api using REST Tool