The
employees
variable will not be
Nothing
if there was no matching employee in the database. Rather, it will be an empty collection.
Change
If (employees Is Nothing) Then
Dim employee As New Employee()
context.Employees.InsertOnSubmit(employee)
context.SubmitChanges()
End If
to
If (employees Is Nothing OrElse employees.Count() < 1) Then
Dim employee As New Employee()
context.Employees.InsertOnSubmit(employee)
context.SubmitChanges()
End If
You should also check whether or not the string comparisons (
lastName.Contains()
and
firstName.Contains()
) you use in your query should be case-sensitive. Right now I believe they are.
For additional help, you'll need to clarify exactly what problems you're having.