本文介绍了在数据库sqlserver中显示数据到表html的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
Hai All帮我,如何显示数据库显示到表格的数据.. ??? 我的代码:
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
推荐答案使用GridView和SQLDataSource显示数据你不确定如何编码。 将GridView拖放到你的页面然后a n SQLDataSource。 查看下面的例子,你应该能够把它搞定。如果你仍然卡住那么请告诉我们。 asp-net-example.blogspot.sg/2008/10/gridview-example-how-to-populate.html [ ^ ] 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. asp-net-example.blogspot.sg/2008/10/gridview-example-how-to-populate.html[^]
更多推荐
在数据库sqlserver中显示数据到表html
发布评论