Click here to Skip to main content
15,911,646 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
error message

txt_pay' has a SelectedValue which is invalid because it does not exist in the
list of items. Parameter name: value



Select
@ZAPPRS_NO = APPRS_NO ,
@ZBANKCODE = BANKCD ,
@ZPAY = PAY_TYPE ,
@ZACT_STAT = PAYRUN ,
@ZBANKNAME = BANKNAME ,
@ZINT_CODE = INT_NO
from LOANS Where IDNO= @ZIDNO AND APPRS_NO=@ZAPPRS_NO AND LOANUMBER=@ZLOANUMBER

The above gives the error message


Select
@ZAPPRS_NO = APPRS_NO ,
@ZBANKCODE = BANKCD ,
@ZPAY = PAY_TYPE ,
@ZACT_STAT = PAYRUN ,
@ZBANKNAME = BANKNAME ,
@ZINT_CODE = INT_NO
from LOANS Where IDNO= @ZIDNO AND APPRS_NO=@ZAPPRS_NO

However when I take of the 3rd condition the progam works "LOANUMBER=@ZLOANUMBER:

txt_Pay is a drop down list

What I have tried:

Checked on the internet but there is no example on select statement
Posted
Updated 1-Nov-16 17:36pm
v2
Comments
phil.o 1-Nov-16 18:26pm    
"there is no example on select statement"
Sorry, but I seriously doubt that.
Since you did not tell which database engine you are working with, it's hard to give you an appropriate link.
You tagged your question as C# and ASP.NET, but apparently what it should be tagged with is the database engine (MSSQL, Oracle, MySQL, etc...).
Member 12770648 2-Nov-16 0:38am    
sorry the database is MSSQL -2008

HANKS

1 solution

From what I gather, the problem is not in the SQL statement itself but in the code where you call or bind the statement.

You seem to have an object named txt_pay and you try to get a value from it using SelectedValue property. This fails because there is no selection or the value isn't bound to your select statement.

Double check all the parameter bindings int the ASP.NET code. For an example, have a look at SqlDataSource.SelectParameters Property (System.Web.UI.WebControls)[^]
 
Share this answer
 
v2

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