Execute Scalar to trap error in case of no records returned

后端 未结 4 1561
轻奢々
轻奢々 2021-01-20 06:33

I have got this code below:

Dim lJobName As String = \"\"
SQLCommand.CommandText = \"Select JobName from Jobs where Id = @Id \"
SQLCommand.Parameters.Add(New         


        
4条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2021-01-20 07:11

    I think it is possible to handle this situation in the statement of the query:

    SELECT ISNULL(FieldID,"0") FROM TableName

    and subsequently in the program validate the result:

    if then ...... else ...... endif

提交回复
热议问题