I am using MySQL in a VB 2013 project. I am trying to get the number of records in a table running
Dim SQLstr As String = "SELECT COUNT(*) FROM lieferantenartikel WHERE LiefID=1 AND LfAIDLief=1"
Dim CheckExist As New MySqlCommand(SQLstr, New MySqlConnection(strConn))
Try
Dim recEx As Integer = CheckExist.ExecuteScalar()
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try
By definition COUNT(*) is supposed to return a scalar number, i.e. 0 if no records exist or otherwise any other positive number.
But I am getting a System.NullReferenceException. What am I doing wrong?