Dim rs As ADODB.Recordset
Dim arr()
...
arr = rs.GetRows()
Set rstDep = DBconn.Execute("select distinct uid from problems")
rstDep.Fields.Count
select distinct uid from problems
While Not rstDep.EOF
Debug.print rstDep!uid
rstDep.MoveNext
Wend
teCa писал(а):...по запрос
- Код: Выделить всё
select distinct uid from problems
возвращает намного больше?
DBconn.Open (DataEnvironment1.Connection1)
Set rstDep = DBconn.Execute("select distinct department from problems")
While Not rstDep.EOF
Set rstUsr = DBconn.Execute("select distinct uid from problems where department=" & "'" & rstDep!department & "'")
While Not rstUsr.EOF
collUsr.Add rstUsr!uid, CStr(rstUsr!uid)
rstUsr.MoveNext
Wend
'collDep.Add rstDep!department, CStr(rstDep!department)
rstDep.MoveNext
Wend
While Not rstDep.EOF
Set rstUsr = DBconn.Execute("select distinct uid from problems where department=" & "'" & rstDep!department & "'")
While Not rstUsr.EOF
collUsr.Add rstUsr!uid, CStr(rstUsr!uid)
rstUsr.MoveNext
Wend
collDep.Add collUsr, CStr(rstDep!department)
rstDep.MoveNext
Wend
sub x()
dim collUsr as Collection
While Not rstDep.EOF
Set rstUsr = DBconn.Execute("select distinct uid from problems where department=" & "'" & rstDep!department & "'")
Set collUsr = New Collection
While Not rstUsr.EOF
collUsr.Add rstUsr!uid, CStr(rstUsr!uid)
rstUsr.MoveNext
Wend
collDep.Add collUsr, CStr(rstDep!department)
rstDep.MoveNext
Wend
end sub
Wend
collDep.Add collUsr, CStr(rstDep!department)
Debug.Print collDep(rstDep!department)
rstDep.MoveNext
Wend
А резве в итоге я не буду каждый раз переписывать одну и туже подколлекцию и менять её ключ?
Потому что collDep(x) возвращает то, что ты в нее положил - другую коллекцию, а не число или строку.А на Debug.Print collDep(rstDep!department) спотыкается.
Сейчас этот форум просматривают: Google-бот и гости: 38