I want to get a value from a SQL Server column ID and show it on label.text with help the of following code:
Sub getID()
Dim selquery As String = ("select max(id)+1 from picture1")
Dim command As New SqlCommand(selquery, con)
con.Open()
Label1.Text = (command.ExecuteScalar)
con.Close()
End Sub
The scenario is to get maximum value from ID make it plus 1, and assign it to label.text, it works correctly when I have at least one record in my SQL Server table but if I have no record in my table picture1 then it shows error
