I have got this code below:
Dim lJobName As String = \"\"
SQLCommand.CommandText = \"Select JobName from Jobs where Id = @Id \"
SQLCommand.Parameters.Add(New
I try to avoid comparing a string to Nothing, even though it does work in VB.
The Visual Basic .NET runtime evaluates Nothing as an empty string; that is, "". The .NET Framework, however, does not, and will throw an exception whenever an attempt is made to perform a string operation on Nothing.
Plus pseudocoder's answer wont work as currently shown (oJobname is never set to anything)
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