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.

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

or i think you can use .value.tostring

Hi,
My Suggestion - Concat Empty String at the End

MP1T(hour, 0) = Convert.ToInt16(rs.Fields("MP1T").Value & "" )
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.