从我已经提供更新的旧VB6应用程序中获取此错误。所以我启动并运行了XP Mode并安装并更新了VB6,并且我已经添加了我要求的菜单选项,但现在我收到了这个错误。
这里有几个这样的错误或类似的例子,我看了很多,但情况并不完全相同,我还是一个非常新手的开发者,我只需要救命。我测试了我在dev服务器上编写的查询和围绕它的VB语法,该部分工作正常。我认为这与结尾附近的结果集逻辑有关:
Private Sub FillDoor()
Dim m_rsDoor As ADODB.Recordset
cboDoorStyle.Clear
Set m_rsDoor = conSQL.Execute("SELECT bpm.[Description] " & _
"FROM tblBrandProductMaster bpm " & _
"INNER JOIN tblDoorStyles ds " & _
"ON ds.DoorStyleCode = bpm.Code " & _
"INNER JOIN tblFamilyDoorStyles fds " & _
"ON bpm.Code = fds.DoorStyleCode " & _
"INNER JOIN tblFamilyLines fl " & _
"ON fds.FamilyLineCode = fl.FamilyLineCode " & _
"WHERE fl.FamilyLineCode = '" & strFamID & "' " & _
"AND ds.DFFactive = 1 " & _
"ORDER BY bpm.[Description] ASC")
Do While Not m_rsDoor.EOF
cboDoorStyle.AddItem m_rsDoor!Description
m_rsDoor.MoveNext
Loop
Set m_rsDoor = Nothing
End Sub
****修改:我正在使用该查询填充应用中的特定下拉菜单,并且SQL server和in the app上同时处理这两个问题。
这里的一些示例使用If循环而不是Do While Not,但它们都完成了同样的事情,我不认为这是问题所在。我也不认为这是问题,因为我从应用程序上的另一个菜单选项复制并粘贴了该部分,当我点击它时该选项有效。当我选择我添加的选项时,它只会抛出错误。
谢谢,感谢任何人提供的帮助。
答案 0 :(得分:0)
修改如下代码:
Private Sub FillDoor()
Dim m_rsDoor As ADODB.Recordset
Set m_rsDoor = New Recordset
Dim ActiveConnection as String
ActiveConnection = "XXXXXXXXXXX"
Dim strSQL as String
strSQL = "SELECT bpm.[Description] " & _
"FROM tblBrandProductMaster bpm " & _
"INNER JOIN tblDoorStyles ds " & _
"ON ds.DoorStyleCode = bpm.Code " & _
"INNER JOIN tblFamilyDoorStyles fds " & _
"ON bpm.Code = fds.DoorStyleCode " & _
"INNER JOIN tblFamilyLines fl " & _
"ON fds.FamilyLineCode = fl.FamilyLineCode " & _
"WHERE fl.FamilyLineCode = '" & strFamID & "' " & _
"AND ds.DFFactive = 1" & _
"ORDER BY bpm.[Description] ASC"
m_rsDoor.open strSQL, ActiveConnection, adOpenStatic, adLockOptimistic
Do While Not m_rsDoor.EOF
cboDoorStyle.AddItem m_rsDoor!Description
m_rsDoor.MoveNext
Loop
Set m_rsDoor = Nothing
End Sub
答案 1 :(得分:0)
当记录集中没有记录时会出现此错误请检查您的查询是否正确并给出记录。
您可以使用该查询共享表中的任何记录。