09-10-17, 09:53 AM
PHP كود :
Private Sub Button1_Click(ByVal sender As Object, ByVal e As EventArgs) Handles Button1.Click
If IsExist(Me.TextBox1.Text) Then
MsgBox("Yes")
Else
MsgBox("No")
End If
End Sub
Function IsExist(ByVal theName As String) As Boolean
Dim lst As New List(Of String)
lst.Add("[NAME] LIKE '" & theName.Trim & "'")
lst.Add("[NAME] LIKE '% " & theName.Trim & "'")
lst.Add("[NAME] LIKE '" & theName.Trim & " %'")
lst.Add("[NAME] LIKE '% " & theName.Trim & " %'")
Dim lk As String = String.Join(" OR ", lst)
Dim cmd As New OleDbCommand(" SELECT COUNT(Name) FROM [Table1] WHERE " & lk, con)
cmd.Parameters.AddWithValue("@p1", TextBox1.Text)
If con.State <> ConnectionState.Open Then con.Open()
Dim cnt = cmd.ExecuteScalar
con.Close()
If cnt > 0 Then
Return True
Else
Return False
End If
End Function
