使用while循环,来取DataReader的值,且把他封装正页面table

目的:封装成页面table,以字符串的形式返回给request

 '将查询的结果写到table中,用于popup显示


        Dim temptable As String = "<table border='0' cellpadding='0' cellspacing='1' style ='background-color:#C0FFFF;width:100%;'>"
’循环行数
        While Dr.Read()
‘循环列数


            For i As Integer = 0 To Dr.FieldCount - 1
                Dim value As String


                If System.Convert.IsDBNull(Dr.GetValue(i)) Then

                    value = "null"
                Else
‘取出该列的值
                    value = Dr.GetValue(i).ToString

                End If
                temptable = temptable + "<tr style='height:20px;'>"
’取出该列的列名字
                temptable = temptable + "<td width='150px' align='center' style ='background-  color:LightGoldenrodYellow'>" + Dr.GetName(i).ToString() + "</td>"
                temptable = temptable + "<td width='150px' align='center'>" + value + "</td>"
                temptable = temptable + "</tr>"
            Next

        End While
        Dr.Close()
        conn.Close()


        temptable += "<table>"

转载于:https://www.cnblogs.com/yansheng9988/archive/2008/03/15/1107001.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值