請各位大哥大姐們幫我看看下面的程式碼??為什麼會有這樣的的錯誤訊息
為何我使用ADODB.Recordset
沒辦法做Delete的動作??
它會出現error 3251 提供者不支援應用程式所要求的動作
我實在不知為什麼也......
Public Sub XmitPreOrder(SysID As String, sErrMsg$)
On Error Resume Next
Dim dsOdr As ADODB.Recordset, sSQL$
Dim sMsgData$, iStatus%, sRetMsg$, NetNo&, OdrNo$
Dim MsgType$, WarmMsg$, STMP$, ret%, idx%
If gconDB Is Nothing Then
If Not OpenNTDB Then
sErrMsg = "資料庫連結失敗,無法傳送!!"
Exit Sub
End If
End If
sErrMsg = ""
MsgType = IIf(SysID = "TSE", Format$(MSG_TSE_OFF), Format$(MSG_OTC_OFF))
sSQL = "SELECT * FROM E_Order WHERE MsgType='" + MsgType + "'"
sSQL = sSQL + " AND OdrNo='00000' ORDER BY NetNo"
retCode = procDBQuery(sSQL, dsOdr)
If dsOdr Is Nothing Or dsOdr.EOF Then
sErrMsg = SysID + " 查無次日單資料!!"
Exit Sub
End If
Do While Not dsOdr.EOF
NetNo = dsOdr("NetNo")
If dsOdr("DelMark") = "D" Then
dsOdr.Delete
^^^^^^^^^^^^^^^^執行到此行就出現錯誤了...why??
End If
dsOdr.MoveNext
Loop
End Sub
Public Function procDBQuery(ByVal sSQL$, ds As ADODB.Recordset) As Variant
On Error Resume Next
Err.Clear
procDBQuery = 0
Set ds = New ADODB.Recordset
ds.CursorType = adOpenKeyset
ds.LockType = adLockOptimistic
ds.Open sSQL, gconDB, , , adCmdText
If Err <> 0 Then
Select Case Err
Case -2147467259: '[DBNMPNTW]ConnectionWrite (GetOverLappedResult()).
gconDB.Close
Set gconDB = Nothing
'Case -2147217900: 'Incorrect syntax
Case -2147217871: 'Timeout expired
End Select
Set ds = Nothing
procDBQuery = Err
ElseIf gconDB.Errors.Count > 0 Then
Select Case gconDB.Errors.item(0)
Case -2147467259: '[DBNMPNTW]ConnectionWrite (GetOverLappedResult()).
gconDB.Close
Set gconDB = Nothing
'Case -2147217900: 'Incorrect syntax
Case -2147217871: 'Timeout expired
End Select
Set ds = Nothing
procDBQuery = gconDB.Errors.item(0)
End If
End Function
謝謝大家