Tharake Gunatilake

Tharake Gunatilake

  • NA
  • 53
  • 71.9k

converting float values

Mar 15 2013 4:28 AM
I get data through a stores procedure from MS SQL db.
the values are,
int ID,
string name,
float distance..

i wrote this code in my c#   DBAccess class.

  rdr = com.ExecuteReader();
                while (rdr.Read())
                {
                    Merchant merchant = new Merchant();

                    merchant.ID = rdr.GetInt32(0);
                    merchant.name= rdr.GetString(1);
                    merchant.distance= rdr.GetFloat(2);

                    lstMerchant.Add(merchant);                   

                } 
but it gives me an exception  "Specified cast is not valid."
This is given by   "merchant.distance= rdr.GetFloat(2);" line...
What can i do??
please help me..Thank you.


Answers (3)