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

Solution 1

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.
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

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
  Permalink  
v2
Comments
Gilbertinino at 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)

  Print Answers RSS
0 OriginalGriff 205
1 Sergey Alexandrovich Kryukov 185
2 jlopez788 144
3 Rob Philpott 100
4 Prakriti Goyal 97
0 OriginalGriff 6,837
1 Sergey Alexandrovich Kryukov 5,559
2 Maciej Los 3,479
3 Peter Leow 3,323
4 DamithSL 2,505


Advertise | Privacy | Mobile
Web02 | 2.8.140721.1 | Last Updated 22 Feb 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100