Hi all,
I am trying to check a record in database before inerting a new record here is my code but problem is when i enter a names first alphabet it imediatly populate massage please help me i want to check it after entering whole name thanks in advance.
Private Sub TextBox1_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox1.KeyPress
Try
Dim cnString As String = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & Application.StartupPath & "\Payment.mdb;"
Dim sqlQRY As String = "SELECT COUNT(*) AS numRows FROM CustomerInformation WHERE CustomerName = '" & TextBox1.Text & "'"
Dim queryResult As Integer
Dim conn As OleDbConnection = New OleDbConnection(cnString)
conn.Open()
Dim com As New OleDbCommand(sqlQRY, conn)
queryResult = com.ExecuteScalar()
conn.Close()
If queryResult > 0 Then
MessageBox.Show("Already Exists!", "ALI ENTERPRISES", MessageBoxButtons.OK, MessageBoxIcon.Information)
TextBox1.Text = ""
Exit Sub
End If
Catch ex As Exception
MessageBox.Show("Customer found" + ex.Message)
End Try
End Sub