使用For ... Loop来检索记录.... [英] Using For ... Loop to retrieve records....

查看:49
本文介绍了使用For ... Loop来检索记录....的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述




我有一个表单,用户可以根据记录选择一个复选框。

每个复选框都带有产品的RecordID。


-------------------------------------- --------------------------


我正在尝试打印以下报告: -


产品详细信息1


---------报告/页面中断----------- ----


产品详情6


---------报告/分页----- ----------


或选择的任何产品。


在打印报告之前,表格提交下一页用

一些代码如下:

对于i = 1到Request.Form(" printme")。计数(其中printme是

复选框的名称)

fieldName = Request.Form.Key(i)

fieldValue = Request.Form.Item(i)


如果Request.Form.key(i)<"提交然后(忽略提交按钮)


strquery =""

strquery =" SELECT * FROM reports"

strquery = strquery& " WHERE((reports.ReportID =''"& fieldValue&

"''));" (等于首先选择的记录)

设置RS = adoDataConn.Execute(strquery)

写出在fieldValue中检索到的第一个ID的报告


else

结束如果

下一页


---------------- ---------------------------------


问题是我做不到得到我的SQL代码来从

获取下一个ID。对于...循环


你能帮助


谢谢


David

Hi,

I have a form on which a user can select a checkbox against a record.
Each checkbox carries the RecordID of a product.

----------------------------------------------------------------

I am trying to print the following report:-

Details for product 1

--------- Report / page Break ---------------

Details for Product 6

--------- Report / page Break ---------------

or for whatever products were selected.

Before the report is printed, the form submits to the next page with
some code as follows:

For i = 1 to Request.Form("printme").Count (where printme is the
name of the checkbox)
fieldName = Request.Form.Key(i)
fieldValue = Request.Form.Item(i)

if Request.Form.key(i) <"Submit" then (Ignore Submit button)

strquery = ""
strquery = "SELECT * FROM reports"
strquery = strquery & " WHERE ((reports.ReportID=''" & fieldValue &
"''));" (equals first selected record)
Set RS = adoDataConn.Execute(strquery)
Write out report for first ID retrieved in fieldValue

else
end if
Next

-------------------------------------------------

The problem is I cannot get my SQL code to pickup the next ID from the
For ... Loop

Can you help

Thanks

David

推荐答案

David写道:
David wrote:




我有一个表单,用户可以根据记录选择一个复选框。

每个复选框都带有产品的RecordID。


-------------------------------- --------------------------------


我正在尝试打印以下报告: -


产品详细信息1


---------报告/页面中断----- ----------


产品详细信息6


---------报告/页面中断---------------


或选择的任何产品。


在打印报告之前,表格提交到下一页

some代码如下:

对于i = 1到Request.Form(" printme")。Count(其中printme是复选框的

名称)


fieldName = Request.Form.Key(i)

fieldValue = Request.Form.Item(i)

$ b如果Request.Form.key(i)<"提交,则为$ b然后(忽略提交按钮)


strquery =""

strquery =" SELECT * FROM reports"

strquery = strquery& " WHERE((reports.ReportID =''"& fieldValue&

"''));" (等于首先选择的记录)


设置RS = adoDataConn.Execute(strquery)


写出在fieldValue中检索到的第一个ID的报告/>

其他

结束如果

下一页


-------- -----------------------------------------


问题是我无法获取我的SQL代码来从
获取下一个ID
For ... Loop
Hi,

I have a form on which a user can select a checkbox against a record.
Each checkbox carries the RecordID of a product.

----------------------------------------------------------------

I am trying to print the following report:-

Details for product 1

--------- Report / page Break ---------------

Details for Product 6

--------- Report / page Break ---------------

or for whatever products were selected.

Before the report is printed, the form submits to the next page with
some code as follows:

For i = 1 to Request.Form("printme").Count (where printme is the
name of the checkbox)
fieldName = Request.Form.Key(i)
fieldValue = Request.Form.Item(i)

if Request.Form.key(i) <"Submit" then (Ignore Submit button)

strquery = ""
strquery = "SELECT * FROM reports"
strquery = strquery & " WHERE ((reports.ReportID=''" & fieldValue &
"''));" (equals first selected record)
Set RS = adoDataConn.Execute(strquery)
Write out report for first ID retrieved in fieldValue

else
end if
Next

-------------------------------------------------

The problem is I cannot get my SQL code to pickup the next ID from the
For ... Loop



第一步:验证Request.Form(printme)包含您认为它包含的内容:


Response.Write Request.Form(" printme" )& "< BR>"


-

Microsoft MVP - ASP / ASP.NET

请回复新闻组。我的From

标题中列出的电子邮件帐户是我的垃圾邮件陷阱,因此我不经常检查它。通过发布到新闻组,您将获得更快的回复。

First step: verify that Request.Form("printme") contains what you think
it contains:

Response.Write Request.Form("printme") & "<BR>"

--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don''t check it very often. You will get a
quicker response by posting to the newsgroup.


6月19日,15:02,Bob Barrows [MVP] " < reb01 ... @ NOyahoo.SPAMcom>

写道:
On 19 Jun, 15:02, "Bob Barrows [MVP]" <reb01...@NOyahoo.SPAMcom>
wrote:

David写道:
David wrote:


Hi,


我有一个表单,用户可以在其中选择一个记录的复选框。

每个复选框都带有产品的RecordID。
I have a form on which a user can select a checkbox against a record.
Each checkbox carries the RecordID of a product.


------------------------------ ----------------------------------
----------------------------------------------------------------


我正在尝试打印以下报告: -
I am trying to print the following report:-


产品详情1
Details for product 1


---------报告/页面中断---------------
--------- Report / page Break ---------------


产品详情6
Details for Product 6


---------报告/分页------- --------
--------- Report / page Break ---------------


或选择的任何产品。
or for whatever products were selected.


在打印报告之前,表格提交到下一页

,代码如下:
Before the report is printed, the form submits to the next page with
some code as follows:


For i = 1 to Request.Form(" printme")。Count(其中printme是复选框的

名称)
For i = 1 to Request.Form("printme").Count (where printme is the
name of the checkbox)


fieldName = Request.Form.Key(i)

fieldValue = Request.Form.Item(i)
fieldName = Request.Form.Key(i)
fieldValue = Request.Form.Item(i)


if Request.Form.key(i)<"" Submit"然后(忽略提交按钮)
if Request.Form.key(i) <"Submit" then (Ignore Submit button)


strquery =""

strquery =" SELECT * FROM reports"

strquery = strquery& " WHERE((reports.ReportID =''"& fieldValue&

"''));" (等于首先选择的记录)
strquery = ""
strquery = "SELECT * FROM reports"
strquery = strquery & " WHERE ((reports.ReportID=''" & fieldValue &
"''));" (equals first selected record)


设置RS = adoDataConn.Execute(strquery)
Set RS = adoDataConn.Execute(strquery)


写出在fieldValue中检索到的第一个ID的报告
Write out report for first ID retrieved in fieldValue


else

结束如果

下一个
else
end if
Next


-------------------------- -----------------------
-------------------------------------------------


问题是我无法得到我的从

获取下一个ID的SQL代码For ... Loop
The problem is I cannot get my SQL code to pickup the next ID from the
For ... Loop



第一步:验证Request.Form(" printme" ;)包含你的想法

它包含:

Response.Write Request.Form(" printme")& "< BR>"


First step: verify that Request.Form("printme") contains what you think
it contains:

Response.Write Request.Form("printme") & "<BR>"



---------------------------------- -------------------------------------------------- -------


它返回正确的记录ID 2533,2567,2568,2566

即我刚刚选择了这4条记录。 />

-------------------------------------------------------------------------------------------

It returns the correct record IDs 2533, 2567, 2568, 2569
i.e. I just selected these 4 records.


6月19日15:17,David< davidgor ... @ scene-double.co.ukwrote:
On 19 Jun, 15:17, David <davidgor...@scene-double.co.ukwrote:

6月19日15:02,Bob Barrows [MVP]" < reb01 ... @ NOyahoo.SPAMcom>

写道:
On 19 Jun, 15:02, "Bob Barrows [MVP]" <reb01...@NOyahoo.SPAMcom>
wrote:

David写道:
David wrote:

您好,
Hi,


我有一个表格供用户选择对记录的复选框。

每个复选框都带有产品的RecordID。
I have a form on which a user can select a checkbox against a record.
Each checkbox carries the RecordID of a product.


------------------ ----------------------------------------------
----------------------------------------------------------------


我正在尝试打印以下报告: -
I am trying to print the following report:-


产品详情1
Details for product 1


---------报告/页面中断---------------
--------- Report / page Break ---------------


产品详情6
Details for Product 6


---------报告/页面中断---------------
--------- Report / page Break ---------------


或选择的任何产品。
or for whatever products were selected.


在打印报告之前,表单提交到下一页

一些代码如下:
Before the report is printed, the form submits to the next page with
some code as follows:


对于i = 1到Request.Form( " printme")。计数(其中printme是复选框的

名称)
For i = 1 to Request.Form("printme").Count (where printme is the
name of the checkbox)


fieldName = Request.Form.Key(i)

fieldValue = Request.Form.Item(i)
fieldName = Request.Form.Key(i)
fieldValue = Request.Form.Item(i)


如果Request.Form.key(i)<"提交然后(忽略提交按钮)
if Request.Form.key(i) <"Submit" then (Ignore Submit button)


strquery =""

strquery =" SELECT * FROM reports"

strquery = strquery& " WHERE((reports.ReportID =''"& fieldValue&

"''));" (等于首先选择的记录)
strquery = ""
strquery = "SELECT * FROM reports"
strquery = strquery & " WHERE ((reports.ReportID=''" & fieldValue &
"''));" (equals first selected record)


设置RS = adoDataConn.Execute(strquery)
Set RS = adoDataConn.Execute(strquery)


写出在fieldValue
中检索到的第一个ID的报告
Write out report for first ID retrieved in fieldValue


else

end if

Next
else
end if
Next


---------------------------- ---------------------
-------------------------------------------------


问题是我无法获取我的SQL代码来从

获取下一个ID For ... Loop
The problem is I cannot get my SQL code to pickup the next ID from the
For ... Loop


第一步:验证Request.Form(printme)续ains你的想法

它包含:
First step: verify that Request.Form("printme") contains what you think
it contains:


Response.Write Request.Form(" printme")& "< BR>"
Response.Write Request.Form("printme") & "<BR>"



---------------------------------- -------------------------------------------------- -------


它返回正确的记录ID 2533,2567,2568,2569

即我刚刚选择了这4条记录。


-------------------------------------------------------------------------------------------

It returns the correct record IDs 2533, 2567, 2568, 2569
i.e. I just selected these 4 records.



---------------------------------- -------------------------------------------------- --------------------


好​​的,现在我还有一点,如果我选择1复选框,它打印1

报告,如果我选择2条记录,它会打印2条报告,但如果我选择3条

条记录,则会在页面底部抛出此错误:


请求对象错误''ASP 0105:80004005''

指数超出范围

/Repair_Reports/index_Report_Multi.asp,line 16

数组索引超出范围。


我目前的代码是:


---- -------------------------------------------------- -------------


对于i = 1到Request.Form(printme)。计数


fieldName = Request.Form.Key(i)

fieldValue = Request.Form.Item(i)


if Request.Form.Item( i)<提交然后


strquery =" SELECT * FROM reports"

strquery = strquery& " WHERE((reports.ReportID =''"&

Request.Form(" printme")。item(i)&"''));"


设置RS = adoDataConn.Execute(strquery)


做的时候不RS.EOF


打印记录等< xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx>


RS.Movenext


循环


其他

结束如果


下一页


--------------------- -----------------------------------------------


如上所述,这适用于1或2个选定的记录,

3次或更多次崩溃............你能不能请解释这个???


谢谢


David

--------------------------------------------------------------------------------------------------------

ok, now I''ve got a little further, If I select 1 checkbox, it prints 1
report, if I select 2 records, it prints 2 reports, but if I select 3
records it throws this error at the bottom of the page:

Request object error ''ASP 0105 : 80004005''
Index out of range
/Repair_Reports/index_Report_Multi.asp, line 16
An array index is out of range.

My current code is:

-------------------------------------------------------------------

For i = 1 to Request.Form("printme").Count

fieldName = Request.Form.Key(i)
fieldValue = Request.Form.Item(i)

if Request.Form.Item(i) <"Submit" then

strquery = "SELECT * FROM reports"
strquery = strquery & " WHERE ((reports.ReportID=''" &
Request.Form("printme").item(i) & "''));"

Set RS = adoDataConn.Execute(strquery)

Do while NOT RS.EOF

print records etc < xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx >

RS.Movenext

Loop

else
end if

Next

--------------------------------------------------------------------

As mentioned above, this works perfectly for 1 or 2 selected records,
bu crashes on 3 or more ........... can you explain this please ???

Thanks

David


这篇关于使用For ... Loop来检索记录....的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆