我每次运行查询时都试图创建一个新的结果集......这样当我显示信息时,我将为不同的表格提供不同的结果集...是否可以更改for循环中结果集的名称?
这样的东西可以解释我的意思..在最后一行我做一个For i = 0来计算-2 ...我想知道我是否可以拥有rsTemp(1,2,3,4,5)设置为I,如果我有5个查询...我会有rsTemp1,rsTemp2,rsTemp3,rsTemp4和rsTemp5:
'1st Table Informations
strSQL = "SELECT DISTINCT custpart FROM dex_racklabels..rl_master where custpart like '%-%' and userid <> 'dakkota' and status <> 'S'"
Set rsTemp5 = conPaintDC.Execute(strSQL)
If Not rsTemp5.EOF Then
'If this returns something create an array of the returned rack serial numbers
Do While Not rsTemp5.EOF
strArrayPart = strArrayPart & "'" & rsTemp5("custpart") & "',"
rsTemp5.MoveNext
Loop
rsTemp5.MoveFirst
End If
'Split up the Part Numbers
ArraySplit = Split(strArrayPart,",")
'Count how many items you have
For each item In ArraySplit
count = count + 1
Next
'Run query for each
For i = 0 to count - 2
strSQL = "SELECT COUNT(serialnbr) FROM [dex_racklabels].[dbo].[rl_detail] where custpart = " & ArraySplit(i) & ""
Set rsTemp(1,2,3,4,5) = conPaintDC.Execute(strSQL)
If Not rsTemp(1,2,3,4,5).EOF Then
response.write(strSQL)
End If
Next
response.end()
答案 0 :(得分:0)
&#34;编号&#34;变量(例如rsTemp1,rsTemp2,...)是一个坏主意,应该避免。在你的情况下 - 循环处理许多记录集顺序 - 根本不需要额外/特殊/花哨变量,重新使用局部变量就足够了:
For Each query_spec
Set oRS = Obtain rs from query_spec
display oRS
close oRS
Next
如果您需要同时使用多个记录集,请使用集合(数组,字典):
init collection c()
For Each query_spec
Set c(query_spec) = Obtain rs from query_spec
Next
For i = 1 To UBound(c) Step 2
WorkWith2Rs c(i-1), c(i)
Next