Handling ExecuteScalar() when no results are returned

后端 未结 22 1153
猫巷女王i
猫巷女王i 2020-11-27 05:47

I am using the following SQL query and the ExecuteScalar() method to fetch data from an Oracle database:

sql = \"select username from usermst wh         


        
22条回答
  •  半阙折子戏
    2020-11-27 06:12

    Try this code, it appears to solve your problem.

    Dim MaxID As Integer = Convert.ToInt32(IIf(IsDBNull(cmd.ExecuteScalar()), 1, cmd.ExecuteScalar()))

提交回复
热议问题