Nel

Nel

  • NA
  • 716
  • 1.1m

Problem with conversion from object to int32

May 4 2011 7:44 AM

Hello,

I once thought that I solved this problem, but I got it again, and I don't know what is the problem.

When I put only

pom = distpostSqlCommand1.ExecuteScalar()
TextBox4.Text = pom.ToString();

I get correct value in my textbox but when I try to convert it in Int32, since I need it to compare with a minimum value and use

Int32 rast = Convert.ToInt32(pom);

I get an error:

Exception Details: System.InvalidCastException: Object cannot be cast from DBNull to other types.

Source Error:

Line 119:            TextBox4.Text = pom.ToString();
Line 120:            Int32 rast = Convert.ToInt32(pom);


Answers (10)