I am creating, opening and then disconnecting a recordset against a MySQL database. This works correctly for one query but returns 0 records for another query where the rows exist in the database. Where it works, I can delete the records from the recordset as well.
The query that returns records:
sql = "select convert(v.wonotes using UTF8) as WonData, v.wo_cat_id, v.id As wo_desc_id, v.line_no as line_no, " & _
" v.wo_id as wo_id, v.prop_id as prop_id, convert(v.description using UTF8) as description, v.cat_id as cat_id, " & _
" v.completion_date as completion_date from vw_property_wo_desc v " & _
" where v.wo_cat_id= 6 and **(v.wo_status = 'completed' or v.wo_status = 'approved')** " & _
" and v.wonotes is not null and v.wonotes<> '' "
The query that does NOT return records:
sql = "select convert(v.wonotes using UTF8) as WonData, v.wo_cat_id, v.id As wo_desc_id, v.line_no as line_no, " & _
" v.wo_id as wo_id, v.prop_id as prop_id, convert(v.description using UTF8) as description, v.cat_id as cat_id, " & _
" v.completion_date as completion_date from vw_property_wo_desc v " & _
" where v.wo_cat_id= 6 and **v.wo_status = 'unassigned'** " & _
" and v.wonotes is not null and v.wonotes<> '' "
There is no other change.
If I change the cursor type to adOpenDynamic, the query returns records, but I cannot then disconnect it. This is just to prove that the database has records satisfying that query.
Code for disconnected recordset:
With rsToUse
If .State = adStateOpen Then .Close
.ActiveConnection = GetConnection
.Source = sql
.CursorLocation = adUseClient
.CursorType = adOpenForwardOnly
.LockType = adLockBatchOptimistic
.Open
If .EOF Then
.Close
Exit Function
End If
.ActiveConnection = Nothing
End With
I have run out of ideas, please help.