Below was recommended to use in case string is returned from scalar
Dim lJobName as String = String.Empty
Dim oJobName as object = SqlCommand.ExecuteScalar()
If oJobName Is Nothing Then
'Do something with the error condition
Else
lJobName = oJobName.ToString
End If
How can I make a generic function which will help me to trap other data types also (so execute scalar – can return integer or boolean or string
Regards
You can’t.
ExecuteScalarwill always returnObject, and it’s up to you toCASTin to another datatype.