Click here to Skip to main content
12,451,860 members (65,465 online)
Rate this:
 
Please Sign up or sign in to vote.
See more: ASP.NET
Hai All Help me,, How to Display data from database show to table html ..???
my code :


<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 4-Feb-13 17:25pm
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

Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 1

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[^]
  Permalink  

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

  Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy | Mobile
Web01 | 2.8.160826.1 | Last Updated 5 Feb 2013
Copyright © CodeProject, 1999-2016
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100