Sql server Vb.net:是否可以将sql select语句结果作为html表返回

Sql server Vb.net:是否可以将sql select语句结果作为html表返回,sql-server,vb.net,Sql Server,Vb.net,这是我的密码 Protected Sub Submit_Click(sender As Object, e As EventArgs) Dim sSQL As String sSQL = "Select (ID),fromcur as 'From Currency',tocur as 'To Currency',rate as 'Conversion Rate',cast(convtimestamp as datetime) as 'Updated Time' fr

这是我的密码

 Protected Sub Submit_Click(sender As Object, e As EventArgs)     
 Dim sSQL As String
 sSQL = "Select (ID),fromcur as 'From Currency',tocur as 'To Currency',rate as      'Conversion Rate',cast(convtimestamp as datetime) as 'Updated Time' 
 from Locations.dbo.Uni_Currency_Exchange_Rates 
 where fromCur = '" + FromCur.Text + "' and toCur = '" + ToCur.Text + "' order by ConvTimeStamp desc "
 Location2.SelectCommand = sSQL.ToString
 Dim command3 As New SqlCommand(sSQL, connection)

????????????????

End Sub
我需要生成html表代码 为每个记录创建行


身份证件
从货币
通货
比率
更新时间
1.
2.
.............................
这样显示结果

ID |从货币|到货币|汇率|更新时间

1 | MVR | USD | 15.42 | 3/25/14 12:00:00

1 | MVR | EUR | 22.00 | 3/25/14 12:00:00

实现这一目标有没有捷径


提前感谢

这很容易。有点老派,但我不知道有什么更简单的方法可以做到这一点

创建一个表对象

Dim myTable as Table
在这里创建一个DataReader伪代码

Dim dr as DataReader = command.executeReader
while reader.Read()
TableRow r = new TableRow()
TableCell cell = new TableCell()
cell.Text = reader(0)
r.Cells.Add(cell)
myTable.Rows.Add(r)
next
Table
还公开了标题行和标题单元格的对象。这可能是最简单的方法。(您需要为行中的每一列重复单元格创建和填充,将单元格添加到行中,然后将行添加到表中)


除非您想使用XML、序列化和XSLT,否则我不知道还有其他方法可以做到这一点……

您使用的是ASP.NET吗?您可以创建一个
对象,并用循环填充行和单元格。您可以使用Asp.net 4.5(aspx页面),在这种情况下,您使用的是什么类型的页面?表单?谢谢你的帮助,我刚刚开始使用VBNET。你也可以将表格放到你的页面上(使用You know what-您也可以使用GridView,它会自动填充表格。我完全忘记了这个选项,因为它听起来像是您想用它做一些自定义的事情。是的。您是对的,我正在用它进行自定义编码。我没有使用grid view,因为我无法按我想要的方式格式化行和列使用网格视图,但在表格中我可以像html一样格式化
Dim dr as DataReader = command.executeReader
while reader.Read()
TableRow r = new TableRow()
TableCell cell = new TableCell()
cell.Text = reader(0)
r.Cells.Add(cell)
myTable.Rows.Add(r)
next