yeago Posted March 16, 2006 Share Posted March 16, 2006 Perhaps someone familiar with both ASP and PHP can help me understand some things about how ASP interacts with a SQL2000 database, as well as some syntax translations.First problem:[code]<% if tempCounty <> 0 Then %><OPTION VALUE = "<%=tempCounty%>"><%=tempCountyValue%></OPTION><% end if While (NOT rscCountyList.EOF)%><OPTION VALUE="<%=(rscCountyList.Fields.Item("CountyID").Value)%>"><%=(rscCountyList.Fields.Item("County").Value)%></OPTION><%rscCountyList.MoveNext() WendIf (rscCountyList.CursorType > 0) Then rscCountyList.MoveFirstElse rscCountyList.Requery End If %>[/code]Please, tell me how to make this a simple foreach() in ASP. Quote Link to comment Share on other sites More sharing options...
ober Posted March 16, 2006 Share Posted March 16, 2006 ASP doesn't have a foreach() type function.What's wrong with the code as-is? Quote Link to comment Share on other sites More sharing options...
yeago Posted March 16, 2006 Author Share Posted March 16, 2006 [!--quoteo(post=355618:date=Mar 16 2006, 06:40 PM:name=ober)--][div class=\'quotetop\']QUOTE(ober @ Mar 16 2006, 06:40 PM) [snapback]355618[/snapback][/div][div class=\'quotemain\'][!--quotec--]ASP doesn't have a foreach() type function.What's wrong with the code as-is?[/quote]It does in 10 lines what PHP does in 5?Can you explain to me "Wend" and everything thereafter? Quote Link to comment Share on other sites More sharing options...
ober Posted March 16, 2006 Share Posted March 16, 2006 Yes, ASP is very inefficient.Wend is "While End"... it's like closing a bracket on a while loop in PHP.... and yes, you must include it for one liners.The if statement basically says "if the cursor (which is nothing more than a pointer in the recordset array) can use the MoveFirst call, do it.... otherwise run the query again to reset it at record 0".Hope that helps. Quote Link to comment Share on other sites More sharing options...
yeago Posted March 16, 2006 Author Share Posted March 16, 2006 [!--quoteo(post=355624:date=Mar 16 2006, 06:56 PM:name=ober)--][div class=\'quotetop\']QUOTE(ober @ Mar 16 2006, 06:56 PM) [snapback]355624[/snapback][/div][div class=\'quotemain\'][!--quotec--]The if statement basically says "if the cursor (which is nothing more than a pointer in the recordset array) can use the MoveFirst call, do it.... otherwise run the query again to reset it at record 0".[/quote]Break this down once more? =)I'm very familiar with MySQL/PHP. Put in into those terms?Thanks Quote Link to comment Share on other sites More sharing options...
ober Posted March 16, 2006 Share Posted March 16, 2006 The first part is like using mysql_field_seek() ... the second part is like creating running $result = mysql_query() again. Quote Link to comment Share on other sites More sharing options...
yeago Posted March 16, 2006 Author Share Posted March 16, 2006 This is the simplest way to accomplish this task?Never bothered with mysql_field_seek() =) Quote Link to comment Share on other sites More sharing options...
ober Posted March 16, 2006 Share Posted March 16, 2006 Well, if you need to reset the recordset (not sure why you would want to), yeah. Quote Link to comment Share on other sites More sharing options...
yeago Posted March 16, 2006 Author Share Posted March 16, 2006 By that do you mean go back through the records?Also, what's this mean:<% if tempCounty <> 0 Then %><OPTION VALUE = "<%=tempCounty%>"><%=tempCountyValue%></OPTION><% end if %>Or more importantly. Why would it be there (perhaps its just machine generated junk?) Quote Link to comment Share on other sites More sharing options...
ober Posted March 16, 2006 Share Posted March 16, 2006 Yeah, like if you needed to reuse the recordset for another control or something.I think that's just there so that if something was set in another part of the code, that it will be the first selection... although I don't see any "selected" attribute in the option. I'm assuming at this point without seeing more of the code. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.