VB Code:
Public Function IsDataExist(ByVal Table As String, ByVal Field As String, ByVal value As String, Optional ByVal Operand As String = " = ") As Boolean
Dim RS as ADODB.Recordset
Try
RS=New ADODB.Recordset()
RS.Open("SELECT COUNT(" & Field & ") AS CNT FROM " & Table & " WHERE " & Field & Operand & value, ConCourses, ADODB.CursorTypeEnum.adOpenForwardOnly, ADODB.LockTypeEnum.adLockReadOnly)
IsDataExist = CBool(Val(RS("CNT")) & "")
If RS.State Then RS.Close()
RS = Nothing
Exit_Function:
Exit Function
Catch
MessageBox.Show("IsDataExist" & vbNewLine & Err.Description & vbNewLine & "FROM " & Table & " WHERE " & Field & Operand & value & vbNewLine & Err.Number)
If RS.State Then RS.Close()
RS = Nothing
IsDataExist = False
End Try
End Function