Click here to Skip to main content
15,892,575 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hai All Help me,, How to Display data from database show to table html ..???
my code :


XML
<table class="TableTour2" border="0" cellSpacing="0" cellPadding="0" width="500">
        <tbody>
          <tr>
            <th scope=col>City</th>
            <th scope=col>Deluxe Class</th>
            <th scope=col>Superior Class</th>
            <th scope=col>Standard Class</th>
          </tr>
          <%
              Dim cnnPH As New System.Data.SqlClient.SqlConnection
              Dim drPH As System.Data.SqlClient.SqlDataReader
              Dim cmdPH As System.Data.SqlClient.SqlCommand
               Try
                  cnnPH.ConnectionString = ConStr
                  cnnPH.Open()
                  cmdPH = New System.Data.SqlClient.SqlCommand("SELECT * from tbdata ")

                  drPH = cmdPH.ExecuteReader
                  While drPH.Read
           %>
         <tr>
            <th class=sub><%Response.Write(drPH("CityName"))%> </th>
            <td><%  Response.Write(drPH("HotelName"))%></td>
            <td><%  Response.Write(drPH("HotelName"))%></td>
            <td><%  Response.Write(drPH("HotelName"))%></td>
          </tr>
              <%

              End While
                  drPH = Nothing
                  cnnPH.Close() : cnnPH = Nothing
          Catch ex As Exception
              MsgBox(ex.Message)
              drPH = Nothing
              cnnPH.Close() : cnnPH = Nothing
          End Try
%>
         </tbody>
      </table>


but data not display

thanks
Posted
Updated 4-Feb-13 17:35pm
v2
Comments
AshishChaudha 5-Feb-13 1:03am    
why you are using HTML..?? why not gridview??
simanungkalit 5-Feb-13 2:10am    
i have problem with modification Header table

Example Table:

<table class="TableTour2" border="0" cellSpacing="0" cellPadding="0" width="500">
<tr>
<td width="157" rowspan="2"><div align="center">No</div></td>
<td colspan="4"><div align="center">Class</div></td>
</tr>
<tr>
<td width="147"><div align="center">City</div></td>
<td width="137"><div align="center">Deluxe Class</div></td>
<td width="162"><div align="center">Superior Class</div></td>
<td width="75"><div align="center">Standard Class</div></td>
</tr>
<%
Dim cnnPH As New System.Data.SqlClient.SqlConnection
Dim drPH As System.Data.SqlClient.SqlDataReader
Dim cmdPH As System.Data.SqlClient.SqlCommand
Try
cnnPH.ConnectionString = ConStr
cnnPH.Open()
cmdPH = New System.Data.SqlClient.SqlCommand("SELECT * from tbdata ")

drPH = cmdPH.ExecuteReader
While drPH.Read
%>
<tr>
<td><%Response.Write(drPH("CityName"))%> </td>
<td><% Response.Write(drPH("HotelName"))%></td>
<td><% Response.Write(drPH("HotelName"))%></td>
<td><% Response.Write(drPH("HotelName"))%></td>
</tr>
<%

End While
drPH = Nothing
cnnPH.Close() : cnnPH = Nothing
Catch ex As Exception
MsgBox(ex.Message)
drPH = Nothing
cnnPH.Close() : cnnPH = Nothing
End Try
%>
</table>

=====================================
If i Display with gridview i not have modification header

thanks

1 solution

Use a GridView and a SQLDataSource to display the data if your not sure on how to code it in.
Drag and drop a GridView on to your Page and then an SQLDataSource.
Check the example below you should be able to make it out. if your still getting stuck then let us know.
http://asp-net-example.blogspot.sg/2008/10/gridview-example-how-to-populate.html[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900