I'm quite confused by this..
I am testing if a sql recordset contains records.. normal stuff..
The WHERE statement is based on input parameters and will insert either 'LIKE' or 'NOT LIKE' condition on the 'Role' field...
When copying the built SQL into a query and running, both return a number of records.. However, when testing .BOF / .EOF the SQL using 'LIKE' returns TRUE..
Here is my code..
Any ideas ?
I am testing if a sql recordset contains records.. normal stuff..
The WHERE statement is based on input parameters and will insert either 'LIKE' or 'NOT LIKE' condition on the 'Role' field...
When copying the built SQL into a query and running, both return a number of records.. However, when testing .BOF / .EOF the SQL using 'LIKE' returns TRUE..
Here is my code..
Code:
Public Function gblnProcessData(ByRef pobjConn As ADODB.Connection, pstrDataset As String) As Boolean
On Error GoTo PROC_ERR
Dim objRst As New ADODB.Recordset
Dim strDatasetWhere As String
Dim strSQL As String
' Build WHERE clause based on input parameters
Select Case pstrDataset
Case "ORACLE"
strDatasetWhere = " Role Not Like 'Business Procurement*' "
Case "IPROCUREMENT"
strDatasetWhere = " Role Like 'Business Procurement*' "
Case Else
MsgBox "Unexpected Dataset Parameter", vbCritical, "Processing Aborted !"
GoTo PROC_EXIT
End Select
strSQL = ""
strSQL = strSQL & "SELECT RACFID, MaxSequence " & vbNewLine
strSQL = strSQL & " FROM Import " & vbNewLine
strSQL = strSQL & " WHERE " & strDatasetWhere & vbNewLine
strSQL = strSQL & "ORDER BY RACFID, Role"
Debug.Print strSQL
' ' Write sequence numbers
objRst.Open strSQL, pobjConn, adOpenDynamic, adLockOptimistic
If objRst.EOF Then
MsgBox "No data has been imported !", vbCritical, "NO DATA !"
ElseIf objRst.BOF Then
MsgBox "No data has been imported !", vbCritical, "NO DATA !"
Else
' do some processing
Any ideas ?
Last edited: