|
-
Oct 5th, 2002, 01:08 PM
#1
Thread Starter
Registered User
small problem
i cannot figure out why the RS is not recognized in the catch area.
code:
please try to help
Public Function IsDataExist(ByVal Table As String, ByVal Field As String, ByVal value As String, Optional ByVal Operand As String = " = ") As Boolean
Try
Dim RS As 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
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|