我正在针对 MySQL 数据库创建、打开然后断开记录集。这适用于一个查询,但对于数据库中存在行的另一个查询返回 0 条记录。在它工作的地方,我也可以从记录集中删除记录。
返回记录的查询:
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<> '' "
不返回记录的查询:
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<> '' "
没有其他变化。
如果我将游标类型更改为 adOpenDynamic,查询会返回记录,但我无法断开它。这只是为了证明数据库有满足该查询的记录。
断开记录集的代码:
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
我的想法已经用完了,请帮忙。