找回密码
 立即注册

QQ登录

只需一步,快速开始

工控课堂 首页 工控文库 上位机编程 查看内容

ASP.NET Web Pages - C#-显示数据库数据

2022-3-12 21:56| 发布者: gk-auto| 查看: 579| 评论: 9|原作者: gk-auto

摘要: ASP源代码:@{ var db = Database.Open(SmallBakery); var query = SELECT * FROM Product; } html body h1Small Bakery Products/h1 table border=1 width=100% tr thId/th thProduct/th thDescription/th ...
ASP源代码:
@{
var db = Database.Open("SmallBakery");
var query = "SELECT * FROM Product";
}
<html>
<body>
<h1>Small Bakery Products</h1>
<table border="1" width="100%">
<tr>
<th>Id</th>
<th>Product</th>
<th>Description</th>
<th>Price</th>
</tr>
@foreach(var row in db.Query(query))
{
<tr>
<td>@row.Id</td>
<td>@row.Name</td>
<td>@row.Description</td>
<td align="right">@row.Price</td>
</tr>
}
</table>
</body>
</html>
运行结果:
Small Bakery Products
IdProductDescriptionPrice
1BreadBaked fresh every day
2.99
2Strawberry CakeMade with organic strawberries
9.99
3Apple PieSecond only to your mom's pie
12.99
4Pecan PieIf you like pecans, this is for you
10.99
5Lemon PieMade with the best lemons in the world
11.99
6CupcakesYour kids will love these
9.99

关注公众号,加入500人微信群,下载100G免费资料!
发表评论

最新评论

引用 lacopo 2025-11-21 00:59
来凑个热闹,为楼主增加点人气!
引用 喜欢悠闲独自在 2025-11-21 01:01
这评论区卧虎藏龙,个个都是人才!
引用 源123 2025-11-21 01:02
说得对!狠狠赞同,没毛病~
引用 菜鸽子 2025-11-21 01:04
水个经验,楼主加油,支持你~
引用 婠爸 2025-11-21 01:05
原来还有这种操作,长见识了!
引用 q023057866 2025-11-21 01:06
同款经历!简直是世另我
引用 jpjdxlh 2025-11-21 01:07
理性围观,感觉大家说的都有道理~
引用 wx_gu4Hvi8l 2025-11-21 01:09
评论区人才辈出,笑到停不下来😂
引用 bioler 2025-11-21 01:11
被戳中笑点 / 泪点,太真实了!

查看全部评论(9)

热门文章
关闭

站长推荐上一条 /1 下一条

QQ|手机版|免责声明|本站介绍|工控课堂 ( 沪ICP备20008691号-1 )

GMT+8, 2025-12-23 00:38 , Processed in 0.081136 second(s), 29 queries .

Powered by Discuz! X3.5

© 2001-2025 Discuz! Team.

返回顶部