当前位置:编程学习 > VB >>

重新发贴,请求大侠帮助!

问题描述:
此函数用来查询仓单在MFG/PRO中的状态,若存在则不上传该FTN No资料,读取其备注信息(ftnlot_remarks_2),函数置假;否则则上传其资料,函数置真。
问题在于现在我在MFG/PRO中可查询到某仓单的信息,但rdors.EOF却为真,即无该仓单资料。
请各位达人帮忙看看,该函数的问题所在,多谢!
'-----------Function: Get FTN No exists status
'---------Parameters: sFTNNo : FTN No
'-------------------- sPart : Part No 
'--------Create Date: 06/15/2010
Private Function GetFTNNo(ByVal sFTNNo As String, ByVal sPart As String) As Boolean
Dim strSQL As String
Dim rdors As RDO.rdoResultset
Dim bFirst As Boolean
Dim strLotNo As String

On Error GoTo Handle_Err

If cnQIMS.State = adStateClosed Then
  cnQIMS.Open
End If

strLotNo = sFTNNo

If InStr(1, strLotNo, "R") > 0 Then
  strLotNo = Left(strLotNo, Len(strLotNo) - 2)
End If

strSQL = "select ftnlot_nbr, ftnlot_remarks_2 from ftnlot_mstr where ftnlot_nbr like '" & strLotNo & "%'"

With cmdGetCompany
  .Parameters("@part").Value = sPart
  .Execute
  If Trim(.Parameters("@company").Value) = "" Then
  GetFTNNo = False
  Remark = "Can not get company code"
  Exit Function
  End If

  If Trim(.Parameters("@company").Value) = "welco" Then
  Set rdors = cnWongDB.OpenResultset(strSQL, rdOpenForwardOnly, rdConcurReadOnly)
  End If
  If Trim(.Parameters("@company").Value) = "wellop" Then
  Set rdors = cnWongDB.OpenResultset(strSQL, rdOpenForwardOnly, rdConcurReadOnly)
  End If
End With

If Not rdors.EOF Then
  GetFTNNo = False
  Remark = Trim(rdors("ftnlot_remarks_2"))
Else
  GetFTNNo = True
  
End If

Set rdors = Nothing
Exit Function

Handle_Err:
blOpenL1000DB = False
  Set rdors = Nothing
  GetFTNNo = False
  Remark = ""
  Err.Clear
End Function --------------------编程问答--------------------
'问题描述:
'此函数用来查询仓单在MFG/PRO中的状态,若存在则不上传该FTN No资料,读取其备注信息
'(ftnlot_remarks_2),函数置假;否则则上传其资料,函数置真。
'问题在于现在我在MFG/PRO中可查询到某仓单的信息,但rdors.EOF却为真,即无该仓单资料。
'请各位达人帮忙看看,该函数的问题所在,多谢!
'-----------Function: Get FTN No exists status
'---------Parameters: sFTNNo : FTN No
'-------------------- sPart : Part No
'--------Create Date: 06/15/2010
Private Function GetFTNNo(ByVal sFTNNo As String, ByVal sPart As String) As Boolean
    Dim strSQL As String
    Dim rdors As RDO.rdoResultset
    Dim bFirst As Boolean
    Dim strLotNo As String
    
    On Error GoTo Handle_Err
    
    If cnQIMS.State = adStateClosed Then
        cnQIMS.Open
    End If
    
    strLotNo = sFTNNo
    
    If InStr(1, strLotNo, "R") > 0 Then
        strLotNo = Left(strLotNo, Len(strLotNo) - 2)
    End If
    
    strSQL = "select ftnlot_nbr, ftnlot_remarks_2 from ftnlot_mstr where ftnlot_nbr like '" & strLotNo & "%'"
    
    With cmdGetCompany
        .Parameters("@part").Value = sPart
        .Execute
        
        If Trim(.Parameters("@company").Value) = "" Then
            GetFTNNo = False
            Remark = "Can not get company code"
            Exit Function
        End If
        
        '-----------这两个记录不是并存吧?
'        If Trim(.Parameters("@company").Value) = "welco" Then
'            Set rdors = cnWongDB.OpenResultset(strSQL, rdOpenForwardOnly, rdConcurReadOnly)
'        End If
'
'        If Trim(.Parameters("@company").Value) = "wellop" Then
'            Set rdors = cnWongDB.OpenResultset(strSQL, rdOpenForwardOnly, rdConcurReadOnly)
'        End If

        '是要这个?
        If Trim(.Parameters("@company").Value) = "welco" Then
            Set rdors = cnWongDB.OpenResultset(strSQL, rdOpenForwardOnly, rdConcurReadOnly)
        ElseIf Trim(.Parameters("@company").Value) = "wellop" Then
            Set rdors = cnWongDB.OpenResultset(strSQL, rdOpenForwardOnly, rdConcurReadOnly)
        End If
        
        '------------
    End With
    
    Debug.Print rdors.recordcount    '加这个看输出,是否有记录?
    
    If Not rdors.EOF Then
        GetFTNNo = False
        Remark = Trim(rdors("ftnlot_remarks_2"))
    Else
        GetFTNNo = True
    End If
    
    Set rdors = Nothing
    Exit Function
    
Handle_Err:
    blOpenL1000DB = False
    Set rdors = Nothing
    GetFTNNo = False
    Remark = ""
    Err.Clear
End Function
--------------------编程问答-------------------- 记录肯定不会并存的。只会满足之一的条件。
Debug.Print rdors.recordcount 返回值为 0 --------------------编程问答--------------------
'        If Trim(.Parameters("@company").Value) = "welco" Then
'            Set rdors = cnWongDB.OpenResultset(strSQL, rdOpenForwardOnly, rdConcurReadOnly)
'        End If
'
'        If Trim(.Parameters("@company").Value) = "wellop" Then
'            Set rdors = cnWongDB.OpenResultset(strSQL, rdOpenForwardOnly, rdConcurReadOnly)
'        End If


这两个什么关系,你这么写肯定不对
--------------------编程问答-------------------- 哦,我错了,你这么写也可以,你设断点调试看看是否执行了这两个 --------------------编程问答-------------------- 南京话和“吴侬软语”一点边都沾不上,楼主要有心理准备 --------------------编程问答-------------------- 发错贴了,楼主无视之 --------------------编程问答-------------------- 断点调试有执行,但数据库里明明有记录的。但就是返回不了值,不知为何? --------------------编程问答--------------------
Private Function GetFTNNo(ByVal sFTNNo As String, ByVal sPart As String) As Boolean
    Dim strSQL As String
    Dim rdors As RDO.rdoResultset
    Dim bFirst As Boolean
    Dim strLotNo As String
    
    On Error GoTo Handle_Err
    
    If cnQIMS.State = adStateClosed Then
        cnQIMS.Open
    End If
    
    strLotNo = sFTNNo
    
    If InStr(1, strLotNo, "R") > 0 Then
        strLotNo = Left(strLotNo, Len(strLotNo) - 2)
    End If
    
    strSQL = "select ftnlot_nbr, ftnlot_remarks_2 from ftnlot_mstr where ftnlot_nbr like '" & strLotNo & "%'"
    
    Debug.Print strSQL   '输出拿到数据库运行
    
    With cmdGetCompany
        .Parameters("@part").Value = sPart
        .Execute
        
        If Trim(.Parameters("@company").Value) = "" Then
            GetFTNNo = False
            Remark = "Can not get company code"
            Exit Function
        End If
        
        '-----------这两个没有什么差别,执行一样的语句
        If Trim(.Parameters("@company").Value) = "welco" Then
            Set rdors = cnWongDB.OpenResultset(strSQL, rdOpenForwardOnly, rdConcurReadOnly)
        End If

        If Trim(.Parameters("@company").Value) = "wellop" Then
            Set rdors = cnWongDB.OpenResultset(strSQL, rdOpenForwardOnly, rdConcurReadOnly)
        End If

        
        '------------
    End With
    
    
    
    If Not rdors.EOF Then
        GetFTNNo = False
        Remark = Trim(rdors("ftnlot_remarks_2"))
    Else
        GetFTNNo = True
    End If
    
    Set rdors = Nothing
    Exit Function
    
Handle_Err:
    blOpenL1000DB = False
    Set rdors = Nothing
    GetFTNNo = False
    Remark = ""
    Err.Clear
End Function
补充:VB ,  基础类
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,