Click here to Skip to main content
15,886,199 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
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");
C#
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();
        }
Posted
Updated 21-Feb-13 5:12am
v2
Comments
Sandeep Mewara 21-Feb-13 11:18am    
Sounds like calculate_amt is a function and not a table. Is so?
Gilbertinino 21-Feb-13 11:20am    
Yes it is function which return an amount depending on poste and district.
Sergey Alexandrovich Kryukov 21-Feb-13 11:23am    
Well, supply parameters for the function.
—SA
Gilbertinino 21-Feb-13 11:25am    
ALTER FUNCTION [dbo].[calculate_amt]
(
@dst nvarchar(50),
@pst nvarchar(50)
)

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.
 
Share this answer
 
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
 
Share this answer
 
v2
Comments
Gilbertinino 22-Feb-13 3:45am    
Ok,now am having an error which is different to the first one.
an error is saying "Index 0 is either negative or above rows count." and it highlight this code
txtAmt.Text = dvm[0]["amt"].ToString();

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900