2010-07-15 72 views
0

我有一個奇怪的問題,我試圖將三個記錄集傳遞給一個方法,使它們在相同的數據庫連接下充滿數據。在運行下面的代碼時,通過查看自定義日誌記錄信息,我可以看到在將傳遞給方法的記錄集分配給方法中的局部變量時出現類型不匹配錯誤。將記錄集傳遞給要填充的組件方法

所以當mthod被稱爲下面得到記錄:

2010年7月15日上午10時59分47秒 - 開始GetALLRecordSets 2010年7月15日上午10時59分47秒 - 開始GetALLRecordSets RS初始化

奇怪的是,這個相同的代碼在我們的beta服務器上工作,其中asp代碼是相同的,並且組件dll是相同的。

有什麼想法可能會導致此問題?


傳統的ASP代碼:

set rs1= createobject("ADODB.Recordset") 
set rs2 =createobject("ADODB.Recordset") 
set rs3 = createobject("ADODB.Recordset") 

set myObj = Server.CreateObject("Component.className") 

call myObj.GetAllRecordSets(rs1, rs2, rs3) 

VB6組件代碼:

Public Sub GetALLRecordSets(ByRef rs1 As Variant, _ 
          ByRef rs2 As Variant, _ 
          ByRef rs3 As Variant) 
On Error GoTo ErrorSpot 

    WriteToLog "Begin GetALLRecordSets", "", 0, "" 

    Dim lngErrNum As Long 
    Dim strErrDesc As String 
    Dim filterStr As String 
    Dim objConn As ADODB.Connection 
    Dim myrs1 As ADODB.Recordset 
    Dim myrs2 As ADODB.Recordset 
    Dim myrs3 As ADODB.Recordset 

    WriteToLog "Begin GetALLRecordSets RS initialization", "", 0, "" 

    Set myrs1 = rs1 
    Set myrs2 = rs2 
    Set myrs3 = rs3 

    WriteToLog "End GetALLRecordSets RS initialization", "", 0, "" 

    Set rs1 = myrs1.Clone 
    Set rs2 = myrs2.Clone 
    Set rs3 = myrs3.Clone 

ExitSpot: 
    'Cleanup 
    Exit Sub 

ErrorSpot: 
    'Save the error information 
    lngErrNum = Err.Number 
    strErrDesc = Err.Description 
    'Log the error 
    WriteToLog "GetALLRecordSets", strErrDesc, lngErrNum, strErrDesc  
End Sub 

回答

0

不同version of MDAC在服務器上?您可能需要創建一個特定版本的Recordset,例如

Set rs1 = CreateObject("ADODB.Recordset.2.8")