0

Em, how to convert a blank data to INTEGER?
I use the code as shown below:

MP1T(hour, 0) = Convert.ToInt16(rs.Fields("MP1T").Value)

but then the field MP1T is previously in VARCHAR format.
It runs smoothly until it found out that the field is blank and cannot be converted.
How can i solve it? Thanks

P/S: Re-declare column data type may be hard to implement.

4
Contributors
3
Replies
5
Views
9 Years
Discussion Span
Last Post by selvaganapathy
0

Em, how to convert a blank data to INTEGER?
I use the code as shown below:

MP1T(hour, 0) = Convert.ToInt16(rs.Fields("MP1T").Value)

but then the field MP1T is previously in VARCHAR format.
It runs smoothly until it found out that the field is blank and cannot be converted.
How can i solve it? Thanks

P/S: Re-declare column data type may be hard to implement.

You could consider checking the data first like

if rs.fields("mp1").value = string.empty then
MP1T(hour, 0) = Convert.ToInt16(a NONE blank data)
else
do what is normal..
end if

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.