Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

SQL / ASP help needed! 1

Status
Not open for further replies.

pwel

Programmer
Aug 18, 1999
79
GB
Hi people,<br><br>I am a newbie to the world of SQL / ASP. I am currently running some tests to get to grips with both areas. I have written a very basic Access db (just 2 tables, joined by thier primary keys). The following code sample works, but the output is only showing 1 field, when it I want it to display 3 fields.<br><br>Any help with this would be greatly appreciated.<br><br>&lt;%@ Language=VBScript %&gt; <br>&lt;HTML&gt; <br>&lt;HEAD&gt; <br>&lt;TITLE&gt;Example 1&lt;/TITLE&gt; <br>&lt;/HEAD&gt;<br>&lt;BODY BGCOLOR=&quot;#003399&quot; TEXT=&quot;#CCFFFF&quot;&gt;&lt;center&gt;<br><br><br>&lt;%&nbsp;&nbsp;Response.Write(&quot;These records are pulled from an MS Access database&quot;)&nbsp;&nbsp;%&gt; <br><br>&lt;BR&gt;&lt;BR&gt;&lt;BR&gt;&lt;BR&gt;<br><br>&lt;%<br><br>sql = &quot;SELECT artists_tbl.artist, records_tbl.recTitle, records_tbl.label&nbsp;&nbsp;FROM artists_tbl, records_tbl WHERE artists_tbl.artistID = records_tbl.artistID&quot;<br><br>set conn = server.createobject(&quot;ADODB.Connection&quot;)<br><br>conn.open &quot;recdb&quot;<br><br>set recor=conn.execute(sql) <br><br><br>%&gt;<br><br>&lt;% do while not recor.eof %&gt;<br><br>&lt;%= recor(0) %&gt; &lt;BR&gt;<br><br>&lt;% recor.movenext <br><br>loop%&gt;<br><br>&lt;% recor.close %&gt;<br><br>&lt;BR&gt;<br>&lt;HR&gt;<br><br>&lt;/center&gt;<br>&lt;/BODY&gt; <br><br>&lt;/HTML&gt;<br><br>Cheers,<br><br>Paul Welding.<br><A HREF="mailto:paul.welding@ans-ltd.com">paul.welding@ans-ltd.com</A>
 
Try this...<br><br>&lt;% do while not recor.eof %&gt;<br><br>&lt;%= recor(&quot;artist&quot;) %&gt; &lt;BR&gt;<br>&lt;%= recor(&quot;recTitle&quot;) %&gt; &lt;BR&gt;<br>&lt;%= recor(&quot;label&quot;) %&gt; &lt;BR&gt;<br><br>&lt;% recor.movenext <br><br>loop%&gt;<br><br>u could have tried...<br><br>&lt;%= recor(0) %&gt; &lt;BR&gt;<br><br>&lt;%= recor(1) %&gt; &lt;BR&gt;<br><br>&lt;%= recor(2) %&gt; &lt;BR&gt;<br><br>hope it helps u<br>Regards<br>Vinod<br><br><br><br>
 
Vinod,<br>&nbsp;&nbsp;&nbsp;You should try to minimize the number of ASP delimiters you use.&nbsp;&nbsp;Every time the IIS server sees a &lt;% it switches from processing HTML to ASP, and continues until it encounters the %&gt;, at which time it switches back to HTML mode.&nbsp;&nbsp;Unnecessary context switching makes the web server work harder.&nbsp;&nbsp;This is especially important with heavy traffic sites.<br><br>Rather than<br><br>&lt;% do while not recor.eof %&gt;<br><br>&lt;%= recor(&quot;artist&quot;) %&gt; &lt;BR&gt;<br>&lt;%= recor(&quot;recTitle&quot;) %&gt; &lt;BR&gt;<br>&lt;%= recor(&quot;label&quot;) %&gt; &lt;BR&gt;<br><br>&lt;% recor.movenext <br><br>loop%&gt;<br><br>You should do this:<br><br>&lt;% <br>do while not recor.eof <br>&nbsp;&nbsp;&nbsp;&nbsp;response.write recor(&quot;artist&quot;) & &quot;&lt;BR&gt;&quot; & _<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;recor(&quot;recTitle&quot;) & &quot;&lt;BR&gt;&quot; & _<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;recor(&quot;label&quot;) & &quot;&lt;BR&gt;&quot;<br>&nbsp;&nbsp;&nbsp;&nbsp;recor.movenext <br>loop<br>%&gt;<br><br><br>It's easier to read that way, too.<br><br><br> <p>nick bulka<br><a href=mailto: > </a><br><a href= > </a><br>
 
Thanks Vinodgk and Nick, both solutions work and have been of great hellp to me.<br><br>Thanks again,<br><br>Paul Welding.
 
Nick<br><br>yep..nick u were right..i think i forgot basics..:))<br>thanks for reminding me..:))<br><br>Regards<br>Vinod
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top