没有为该功能提供参数 [英] Parameters were not supplied for the function

查看:141
本文介绍了没有为该功能提供参数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我运行这段代码时,我得到一个错误:没有为函数''calculate_amt''提供参数。此错误发生在此级别 dam.Fill(dsm,calculate_amt);

When am running this code beloe I get an error of "Parameters were not supplied for the function ''calculate_amt''." and this error occurs at this level dam.Fill(dsm, "calculate_amt");

protected void DropDownList1_TextChanged(object sender, EventArgs e)
        {
            SqlDataAdapter dam = new SqlDataAdapter("select * from calculate_amt where DistrictName='" + DropDownList1.Text + "' and poste='" + DropDownList2.Text + "'", con);
            DataSet dsm = new DataSet();
            dam.Fill(dsm, "calculate_amt");
            DataView dvm = new DataView(dsm.Tables["calculate_amt"]);
            txtAmt.Text = dvm[0]["amt"].ToString();
        }

推荐答案

因为它是一个函数,看起来你错过了什么。



请在此处查看有关错误的详细信息: http://www.sql-server-performance.com/2007/parameters-not-supplied-is/ [ ^ ]



描述:


当您不提供用户定义函数所期望的值时,会出现此错误消息。



后果:

可以解析T-SQL语句,但会在运行时导致错误。



解决方案:

严重级别16的错误由用户生成,可由SQL Server用户修复。只要没有定义该参数的默认值,就必须在用户定义函数中为每个参数提供值。这些提供的值必须明确或隐式地转换为相关参数。
Since it''s a function, it looks like you are missing something.

See the details about the error here: http://www.sql-server-performance.com/2007/parameters-not-supplied-is/[^]

Description:

This error message appears when you don’t supply a value expected by a user-defined function.

Consequences:
The T-SQL statement can be parsed, but causes the error at runtime.

Resolution:
Error of the Severity Level 16 are generated by the user and can be fixed by the SQL Server user. You must supply values for each parameter in a user-defind function as long as there is not default value for that parameter defined. These supplied values must explicitly or implicitly be convertible to the parameter in question.


将代码更改为





protected void DropDownList1_TextChanged(object sender,EventArgs e)

{

SqlDataAdapter dam = new SqlDataAdapter(select * from calculate_amt where DistrictName =''+ DropDownList1。 Text +''和poste =''+ DropDownList2.Text +'',con);

DataSet dsm = new DataSet();

//添加此行以在数据集中定义表名

dsm.Tables.Add(calculate_amt);





dam.Fill(dsm,calculate_amt);

DataView dvm = new DataView(dsm.Tables [calculate_amt]);

txtAmt.Text = dvm [0] [amt]。ToString();

}





使用Fill second参数是tablename和表,其名称类似于calculate_amt未添加到数据集,因此导致错误
change code to


protected void DropDownList1_TextChanged(object sender, EventArgs e)
{
SqlDataAdapter dam = new SqlDataAdapter("select * from calculate_amt where DistrictName=''" + DropDownList1.Text + "'' and poste=''" + DropDownList2.Text + "''", con);
DataSet dsm = new DataSet();
// add this line to define table name in dataset
dsm.Tables.Add("calculate_amt");


dam.Fill(dsm, "calculate_amt");
DataView dvm = new DataView(dsm.Tables["calculate_amt"]);
txtAmt.Text = dvm[0]["amt"].ToString();
}


while using Fill second parameter is tablename and table having name like "calculate_amt" not added to dataset so resulted to error


这篇关于没有为该功能提供参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆