How to convert object to integer.?
object result = cmd.ExecuteScalar();
int id = Convert.ToInt32(result);
int id = Convert.ToInt32(result);
this code gives me error..
Know the answer? Post it. Somebody with the same question will find it here.

int id = (int)result ;for your referenceint i = 123; // a value typeobject o = i; // boxingint j = (int)o; // unboxing
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Balaji PalaniRank #4,480 · 341 reputationPosted Nov 3, 2016, 3:52 AM EDT
Ananth GRank #1,176 · 1.5K reputationPosted Nov 3, 2016, 3:29 AM EDT