Вот одно из решений.Замените:
qry = "update StudentDetails.Students set StudentName=@StudentName,Day=@Day,Month=@Month,Year=@Year,Age=@Age,DateAdmit=@DateAdmit,Gender=@Gender,GuardianName=@GuardianName,Phone=@Phone,Email=@Email,Address=@Address,City=@City,Region=@Region,Photo = CASE WHEN @Photo IS NULL THEN Photo ELSE @Photo END where StudentId='" & txtStudentID.Text & "'"
на:
Dim sbQry As New StringBuilder(1000)
sbQry.Append("update StudentDetails.Students set StudentID=@StudentID,StudentName=@StudentName,Day=@Day,Month=@Month,Year=@Year,Age=@Age,DateAdmit=@DateAdmit,Gender=@Gender,GuardianName=@GuardianName,Phone=@Phone,Email=@Email,Address=@Address,City=@City,Region=@Region")
If img IsNot Nothing Then
sbQry.Append(",Photo=@Photo")
End If
sbQry.Append(" where StudentId='").Append(txtStudentID.Text).Append("'")
cmd = New SqlCommand(sbQry.ToString, cn)
и замените это:
If img Is Nothing Then
cmd.Parameters.Add(New SqlParameter("@Photo", DBNull.Value))
Else
cmd.Parameters.Add(New SqlParameter("@Photo", img))
End If
следующим:
If img IsNot Nothing Then
cmd.Parameters.Add(New SqlParameter("@Photo", img))
End If