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)[
^]