Click here to Skip to main content
15,889,216 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
private void comboPrtn_SelectionChangeCommitted(object sender, EventArgs e)
       {




           ////---------------------------Show price-------------------

               SqlDataAdapter ddamtp = new SqlDataAdapter("select * from assign_price('" + this.comboPrtn.SelectedValue + "')", con);
               DataSet ddsamtp = new DataSet();
               ddamtp.Fill(ddsamtp, "price");
               DataView vddamtp = new DataView(ddsamtp.Tables["price"]);
               txtUprice.Text = vddamtp[0]["PRICE"].ToString();

           ////----------------------------end-------------------------
       }
Posted

Since, as far as I know 0 is not negative, and it can't be either above the rows count, such message is plain wrong.
--Carlo The NitPick

However your code is wrong too (the index is equal to row count):
txtUprice.Text = vddamtp[0]["PRICE"].ToString();

You are accessing vddamtp[0] without being sure such dataview contains, at least, one row.
 
Share this answer
 
Assuming assign_price is a function you created, you need to be sure it returns some values. If it doesn't, then the the line:
C#
txtUprice.Text = vddamtp[0]["PRICE"].ToString();
will give the exception you refer to.
 
Share this answer
 

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