本文介绍了使用oledb.ExecuteScaler()的SUM字段的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好



我想在C#.net中使用ExecuteScalar()函数求和表字段。




}

返回count_para;

}



但不要'返回任何内容,我有以下错误:

指定演员表无效。



非常感谢

Hi all

I wanna to sum table field using ExecuteScalar() function in C#.net


}
return count_para;
}

but don't return anything , and i have following error :
Specified cast is not valid.

thanks a lot

推荐答案

public string Calcu_soud(string stat_pay , string az_ti , string ta_ti)
{
    string gt = string.Empty;
    string _comm_calcu_soud = " SELECT SUM(kala.soud_mounth) AS Expr1 FROM (kala)";
    string _comm_calcu_soud += " WHERE status_pay = ?";
    OleDbParameter[] gh = new OleDbParameter[1];
    gh[0] = new OleDbParameter("status_pay", OleDbType.Char);
    gh[0].Value = Convert.ToString(stat_pay);
    gt =  a.Query_Select_Executescaler_with_para(_comm_calcu_soud, gh).ToString();
    return gt;
}





OleDbParamaters必须按qMarks('?')的顺序添加,因为他们不使用命名参数。事实上,你可以命名你的参数foo或bar,它不会影响命令。



这里有几篇展示正在使用的参数的文章: br />
[ ]

和OleDb和Ado样式参数之间的区别:

[]



希望有所帮助^ _ ^



不要忘记喜欢和订阅:Þ



OleDbParamaters will have to be added in order of the qMarks ('?') as they don't use named parameters. In fact, you can name your parameter foo or bar and it won't effect the command.

Here are a couple of articles that show the parameters being used:
Intermediate OLE DB Consumer with C#[^]
And the difference between OleDb and Ado style parameters:
Parameters - SqlCommand vs. OledbCommand and OdbcCommand[^]

Hope that helps ^_^

Don't forget to like and subscribe :Þ


这篇关于使用oledb.ExecuteScaler()的SUM字段的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

11-02 10:50