I want to stick this

Dim cmd As OleDbCommand = New OleDbCommand("SELECT * FROM 0 WHERE Id = 1", con)
                    Dim reader As OleDbDataReader = cmd.ExecuteReader()
                    If Not reader.HasRows Then
                        MsgBox("Data does not exist")
                    Else
                        MsgBox("Data Exists")
                    End If

and this

If Inc <> -1 Then

                    Dim cb As New OleDb.OleDbCommandBuilder(da)
                    Dim dsNewRow As DataRow
                    da.Fill(ds, "0")dsNewRow = ds.Tables("0").NewRow()


                    dsNewRow.Item("Field1") = TextBox2.Text

                    ds.Tables("0").Rows.Add(dsNewRow)

                    da.Update(ds, "0")

                    MsgBox("New Record added to the Database")

                    con.Close()
                    MsgBox("Database is now Closed")

Into a If Then Statement that doesnt allow the second code to execute if the Data Exists
And to allow code to execute if data doesnt exist

If Not reader.HasRows Then
                        MsgBox("Data does not exist")
                    Else
                        MsgBox("Data Exists")
                        Exit Sub '// skip all remaining code in the Sub.
                    End If

Apparently it has rows because evertime i type in a new record the if not reader has rows statement is ignored any ideas

Dim cmd As OleDbCommand = New OleDbCommand("SELECT * FROM 0 WHERE Id = 1", con)
                    Dim reader As OleDbDataReader = cmd.ExecuteReader()
                    If Not reader.HasRows Then
                        MsgBox("Data does not exist")
                    Else
                        MsgBox("Data Exists")
                        Exit Sub
                    End If

I'm a bit confused on your new question.
What's not responding as needed? Does not Exit Sub?

Edited 5 Years Ago by codeorder: n/a

No it exits the sub, but when i type in data that does not exist it says it exist

This question has already been answered. Start a new discussion instead.