this is my code:
found_product[i] = new Product((int)(dr["productNum"]), (string)(dr["catalogNum"]), (string)(dr["item_Description"]), (string)(dr["productDescription"]), (int)(dr["productAmount"]),(string)(dr["supplier_name"]), (string)(dr["date"]).ToString(), (float)(dr["buyingPrice"]));I have a problem with the "(float)(dr["buyingPrice"])" it's give me an error "Specified cast is not valid."
what can I do?

AlanRank #669 · 3.6K reputationPosted Nov 25, 2008, 2:01 AM EST
It depends on what the type of dr["buyingPrice"] actually is. If it's a double, you could do:
(float)(double)(dr["buyingPrice"])
If it's a decimal:
(float)(decimal)(dr["buyingPrice"])
mali47 reputationPosted Nov 25, 2008, 4:19 AM EST