In a VB.net application using a SQLCE database we are using a SqlCeDataReader to "read" values from the DB. The values are then sent to a webservice.
The problem occurs when we use an IF to check whether a specific DB column is null or not. If it is Null, we get the following error :
The column at the specified ordinal (2) contains DBNull value which can not be represented as a built-in .NET system type. Use SqlTypes or IsDBNull property.
The following is our code snippet :
item.ItemID = rdr.GetString(0)
item.Title = rdr.GetString(1)
If Not rdr.GetString(2) = "" Then
item.SubTitle = rdr.GetString(2)
item.SubTitle = deletedFields.Add(rdr.GetString(2))
How can the IF be written to remove the error ? Thank you.