本文介绍了代码没有拉足够的记录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 嘿帮派。 我有一个代码,我将列出。当varM = 8或16时,脚本工作正常, 并拉出前8或前16,但如果它= 32或64,它只拉动 来自DB的前17条记录。 db是访问权限,这是MS服务器。 这里是代码 < % 如果varm = 8则 设置admin6 = conn.execute("选择前8位用户名,iCHECK来自 members2_tourney其中tourney_id = &&;& varID&"") 否则如果varm = 16那么 set admin6 = conn.execute(" select top 16 username,iCHECK from members2_tourney其中tourney_id ="& varID&"") else如果varm = 32则 set admin6 = conn .execute(" select top 32 username,iCHECK from members2_tourney where tourney_id ="& varID&"") else if varm = 64 then set admin6 = conn.execute(" select top 64 username,iCHECK from members2_tourney w这里tourney_id =" &安培; varID& ") 其他 结束如果 结束如果 结束如果 结束如果 如果不是admin6.EOF而不是admin6.BOF那么 do do admin6.eof varnm = admin6.fields.item(" username")。value varch = admin6.fields.item(" iCHECK")。value 如果varch ="是"然后 rowcolor ="#4477aa" fontcolor =" #ffffff" else rowcolor = " #FFFFF" fontcolor ="#000000" 结束如果 %> 我需要知道的是,是否还有另一种方法可以从数据库中提取一定数量的 记录。之所以它是8的多重,是因为这是锦标赛网站的b $ b,所以括号设置为8的倍数 任何想法? 解决方案 你上面的东西应该有用。对TOP我没有限制我知道 。如果你从 asp运行查询时真的只得到17条记录,那么在Access中运行相同的查询返回32,那么我需要看到一个 repro。 br /> - Microsoft MVP - ASP / ASP.NET 请回复新闻组。这个电子邮件帐户是我的垃圾邮件陷阱所以我 不经常检查它。如果您必须离线回复,请删除 无垃圾邮件 OMG 这样做: dim sql 如果varm> 0然后 sql =" select top" &安培; varm& "用户名,iCHECK来自 &安培; _ " members2_tourney其中tourney_id =" &安培; varID& " Response.write sql 设置admin6 = conn.execute(sql ,, 1)如果不是admin6.EOF则''无需检查EOF和BOF 不,不是来自Access。我很高兴看到你决定使用TOP。较小的程序员会从数据库中提取所有记录并仅处理他们需要的记录。 无关:-) 上面的内容应该有效。我知道对TOP没有限制。如果你在从 asp运行查询时真的只得到17条记录,那么在Access中运行相同的查询返回32,那么我需要看一个 repro。 - - Microsoft MVP - ASP / ASP.NET 请回复新闻组。这个电子邮件帐户是我的垃圾邮件陷阱所以我不经常检查它。如果您必须离线回复,请删除NO SPAM Hey gang.i have a code that i will list. when varM = 8 or 16, the script works fine,and pulls the top 8 or top 16, but if it =32 or 64, it is only pulling thetop 17 records from the DB.db is access and this is MS server.here is the code <%if varm = 8 thenset admin6 = conn.execute("select top 8 username, iCHECK frommembers2_tourney where tourney_id = " & varID & "")else if varm = 16 thenset admin6 = conn.execute("select top 16 username, iCHECK frommembers2_tourney where tourney_id = " & varID & "")else if varm = 32 thenset admin6 = conn.execute("select top 32 username, iCHECK frommembers2_tourney where tourney_id = " & varID & "")else if varm = 64 thenset admin6 = conn.execute("select top 64 username, iCHECK frommembers2_tourney where tourney_id = " & varID & "")elseend ifend ifend ifend if IF NOT admin6.EOF AND NOT admin6.BOF THEN do while not admin6.eof varnm = admin6.fields.item("username").valuevarch = admin6.fields.item("iCHECK").value if varch = "Yes" thenrowcolor = "#4477aa"fontcolor = "#ffffff"elserowcolor = "#FFFFFF"fontcolor= "#000000"end if %> what i need to know, is if there is another way to pull a certain amount ofrecords from a DB. the reason it is in mulitples of 8, is because this isfor a tournament site, so the brackets are set in multiples of 8any ideas?? 解决方案 What you have above should work. There is no limitation on TOP that I knowof. If you are really only getting 17 records when running the query fromasp, wihile the same query run in Access returns 32, then I need to see arepro. --Microsoft MVP - ASP/ASP.NETPlease reply to the newsgroup. This email account is my spam trap so Idon''t check it very often. If you must reply off-line, then remove the"NO SPAM" OMG Do this: dim sql if varm > 0 then sql="select top " & varm & " username, iCHECK from " & _ "members2_tourney where tourney_id = " & varID & "" Response.write sql Set admin6=conn.execute(sql,,1) If not admin6.EOF then ''no need to check both EOF and BOF No. Not from Access, anyways. I''m happy to see that you decided to use TOP. Lesser programmers would have pulled ALL the records from the database and processed only the ones they needed. irrelevant :-) What you have above should work. There is no limitation on TOP that I know of. If you are really only getting 17 records when running the query from asp, wihile the same query run in Access returns 32, then I need to see a repro. -- Microsoft MVP - ASP/ASP.NET Please reply to the newsgroup. This email account is my spam trap so I don''t check it very often. If you must reply off-line, then remove the "NO SPAM" 这篇关于代码没有拉足够的记录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!
09-17 03:41