int i;
int count;
count= ds.Tables[0].Rows.Count;
for (i = 0; i <= count - 1; i++)
label1.Text += ds.Tables[0].Rows[i]["员工工资"].ToString();
使用的时候什么效果都没..累加不了..是要convert么?
int count;
count= ds.Tables[0].Rows.Count;
for (i = 0; i <= count - 1; i++)
label1.Text += ds.Tables[0].Rows[i]["员工工资"].ToString();
使用的时候什么效果都没..累加不了..是要convert么?
解决方案 »
- 求:RSS订阅到Google,Yahoo,qq邮箱的接口源码
- 用c#开发绩效工资管理系统,求教各位~~
- 100分求解应用程序列表或者任务栏任务的 绝对路径 问题。
- 如何将字符串转为SqlDbType
- C#窗体程序实现智能提示
- 如何取textarea中的文本??
- serialport datareceived事件接收,数据不全问题
- private List<string> strList=new List<string>();中<string>怎么解释
- 回发或回调参数无效的问题,急问
- 100 分求,在 98 下装 VS.NET 的详细步骤 !
- 100分悬赏,FTP下载文件不全(FtpWebRequest类),各位大侠救命啊!!!
- System.IO.Directory.Exists(directoryname) C#
int count;
count= ds.Tables[0].Rows.Count;
int sum = 0;
for (i = 0; i <= count - 1; i++)
{
try
{
sum = sum + (int)ds.Tables[0].Rows[i]["员工工资"];
}
catch(Exception)
{
MessageBox.Show("Error");
}
}
label1.Text = sum.ToString();
label1.Text = Convert.ToDecimal(label1.Text)+Convert.ToDecimal(ds.Tables[0].Rows[i]["员工工资"]);
使用excerption ex捕获的异常说是system.invalidCastExcoption:指定的转换无效
foreach(DataRow dr in ds.Tables[0].Rows)
{
sum+=int.Parese(dr["员工工资"].ToString());
}
this.label1.text=sum.ToString();
使用excerption ex捕获的异常说是system.invalidCastExcoption:指定的转换无效
报错..说是 sum+=int.Parse(dr["员工工资"].ToString()); 输入字符串的格式不正确
对了我数据用的是money类型保存在数据库的
用这个转换