Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New Coder
    Join Date
    Apr 2007
    Posts
    18
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Error Show data from DB

    I have some issues, please help me ...
    First, see DB (relate with my part..)


    I want show data from DB, my code follow:
    Code:
    <%   openConn  'open Connection
    	set rsMark = Server.CreateObject("ADODB.Recordset")
    	strSQL = "SELECT * FROM Subject"
    	strSQL = strSQL & " JOIN Mark ON Subject.Subject_id=Mark.Subject_id"
    	strSQL = strSQL & " WHERE Student_id=063106445"
    	rsMark.open strSQL, oConn
    %>
    <table width="100%" border="1" cellspacing="0" cellpadding="2">
    	<%
    	        Response.Write "<tr><th>STT</th>"
    	        Response.Write "<th>Năm học</th>"
    		Response.Write "<th>Học kỳ</th>"
    		Response.Write "<th>Môn học</th>"
    		Response.Write "<th>Kiểm tra</th>"
    		Response.Write "<th>Lần 1</th>"
    		Response.Write "<th>Lần 2</th>"
    	        Response.Write "<th>Học trình</th></tr>"	
    	%>
    	<%  
    		cnt=0   'count number record
    		do while not rsMark.EOF 
    		     cnt = cnt + 1
    	%>
    	<tr>
    		<td><%=cnt%></td>
    		<td><%=rsMark("Year")%></td>
    		<td><%=rsMark("Term")%></td>
    		<td><%=rsMark("Subject_name")%></td>
    		<td><%=rsMark("Test")%></td>
    		<td><%=rsMark("Mark")%></td>
    		<td><%=rsMark("ResistMark")%></td>
    		<td><%=rsMark("No_of_lesson")%></td>	
    	</tr>
    	<% 
    		rsMark.Movenext
    		Loop
            %>
    </table>
    and result at here:


    why data in cell Subject_name, Mark, ResistMark,No_of_lesson not display !
    (I tried run with SQL Query Analyzer and success...string SQL was correct! and results were returned is fully ! ... why ?)
    someone explain for me ... hichic

    thanks a lot !
    Last edited by h2q1; 04-15-2007 at 11:53 AM.

  • #2
    Senior Coder
    Join Date
    Nov 2002
    Location
    North-East, UK
    Posts
    1,265
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Just as a test, what happens if you output the fields from a loop instead of referencing the field name

    Here is an example using a for each loop
    http://www.w3schools.com/ado/ado_display.asp


    Also, try referencing the all of the required field names in the query instead of using *


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •