This is what I have. Im trying to check the datatable to see if a row exists where the employeeID = textbox1 and the date = today, if the table doesnt include this row then create a new row. All that works fine except if the row does exist it still creates a new row as well as update the existing row.

Anyway to prevent this?

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim i As Integer
Dim id As Integer = TextBox1.Text
Dim name As String = TextBox2.Text
Dim drnew As System.Data.DataRow
With DsDailyInfo1.EmployeesDaily
For i = 0 To .Count
If .Item(i)("EmployeeID") = id And .Item(i)("Date") = Today.ToShortDateString Then
If .Rows.Item(i)("In1") = "0" Then
.Rows.Item(i)("In1") = TimeOfDay.ToLongTimeString
ElseIf .Rows.Item(i)("In2") = "0" Then
.Rows.Item(i)("In2") = TimeOfDay.ToLongTimeString
ElseIf .Rows.Item(i)("In3") = "0" Then
.Rows.Item(i)("In3") = TimeOfDay.ToLongTimeString
Else
MsgBox("See Administrator", MsgBoxStyle.Exclamation, "Time Clock")
End If
Exit For
OleDbDataAdapter1.Update(DsDailyInfo1)
Else
drnew = Me.DsDailyInfo1.EmployeesDaily.NewRow
drnew.Item("EmployeeID") = id
drnew.Item("FirstName") = name
drnew.Item("Date") = Today.ToShortDateString
drnew.Item("In1") = TimeOfDay.ToLongTimeString
drnew.Item("In2") = "0"
drnew.Item("In3") = "0"
DsDailyInfo1.EmployeesDaily.Rows.Add(drnew)
MsgBox("New Row Added")
End If
Next
End With

OleDbDataAdapter1.Update(DsDailyInfo1)

End Sub