我有一个奇怪的问题,我试图将三个记录集传递给一个方法,让它们在同一个数据库连接下填充数据。通过在运行下面的代码时查看自定义日志记录信息,我可以看到在将传递给方法的记录集分配给方法中的局部变量时,我收到了类型不匹配错误。
因此,在调用mthod时会记录以下内容:
2010年7月15日上午10:59:47 - 开始GetALLRecordSets 7/15/2010 10:59:47 AM - 开始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 :(得分:0)
服务器上的version of MDAC不同?您可能需要创建特定版本的Recordset,例如
Set rs1 = CreateObject("ADODB.Recordset.2.8")