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?
maliPosted Nov 25, 2008, 9:19 AM
AlanPosted Nov 25, 2008, 7:01 AM
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"])