locked
While ...Wend Recordset in <td> using asp.net RRS feed

  • Question

  • User-893002196 posted

    Dear Sir,

     

    May i know how to do while ...wend the recordset in <td> using asp.net? Below is my source code, it's only show 1st recordset ... but i want to display all recordset like

    |  Home  |   About Us  | Contact Us |

     

    Thank you.

     

    Regards,

    Micheale

    <TABLE cellSpacing=0 cellPadding=0 width="100%" bgColor=#DBD8D1>
    				<TR>
    					<script language="vb" runat="server"> 
    						Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
    							Dim openRS
    							Call dbcon()
    							INSERTSQL="SELECT replace(replace(formname,'*',''),'''''','') as formname,[lineno],ll=Link,replace(Target,' ' ,'') as Target from tbmodule Where upline ='0' and language='english' and status<>'0'  order by id"
    							'response.write(INSERTSQL)
    							'response.end
    							Mcmd = New SqlCommand(INSERTSQL, bcon)
    							bcon.open()
    							openRS = Mcmd.executereader
    							
    							While openRS.read()	
    							'Dim rowUser as DataRow
    							'for i = 0 to openRS.fieldcount -1
    	
    								if (openRS("formname")<>"Logout") then
    									ll=openRS("ll") '"&Main="&openRS("lineno")
    									target=openRS("Target")
    									fname=openRS("formname")
    								else
    									ll=openRS("ll")
    									target="_self"
    									fname=openRS("formname")
    								end if	
    							
    					</script>
    					<TD style="BORDER-LEFT: #ffffff 1px solid; BORDER-BOTTOM: #c5c5c5 1px solid; BORDER-TOP: #ffffff 1px solid; PADDING-RIGHT: 3px; PADDING-LEFT: 3px; FONT-SIZE: 11px; PADDING-BOTTOM: 3px; COLOR: white; PADDING-TOP: 3px; FONT-FAMILY: Tahoma,Verdana,Arial,sans-serif; TEXT-DECORATION: none" align=left bgColor=#DBD8D1 colSpan=2>
    					<A  class=Main href="<%=ll%>" <%if target<>"_Self" then%>target="<%=target%>"<%end if%>><%=fname%></A>
    					</TD>
    					<script language="vb" runat="server"> 
    						'next   
    						End While
    						
    						End Sub
    					</script>
    				</TR>
    			</TABLE>
     
    Thursday, May 7, 2009 9:19 PM

Answers

  • User-1659704165 posted

     Hi,



    /**************************Redaer ***************/


    Dim myConnection As SqlConnection
    Dim myCommand As SqlCommand
    Dim dr As New SqlDataReader()

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

    'Know Clearning Connection


    Dim myConnection As SqlConnection
    Dim myCommand As SqlCommand
    Dim dr As New SqlDataReader()


    myConnection = New SqlConnection("server=localhost;uid=sa;pwd=;database=pubs")
    'establishing connection. you need to provide password for sql server
    Try
    myConnection.Open()
    'opening the connection
    myCommand = New SqlCommand("Select * from discounts", myConnection)
    'executing the command and assigning it to connection
    dr = myCommand.ExecuteReader()
    While dr.Read()
    'reading from the datareader
    %>

    <td> ("discounttype" & <%=dr(0).ToString()%>)</td>
    <td>("stor_id" &<%= dr(1).ToString()%>) </td>


    <%

    'displaying the data from the table
    End While
    dr.Close()
    myConnection.Close()
    Catch e As Exception
    End Try

    end sub
    %>

    Hope it helps

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, May 8, 2009 12:28 AM