Use a while loop to get the value of datareader and encapsulate it into a positive table

Source: Internet
Author: User
Objective: To encapsulate a page table and return it to the request in the form of a string

'Write the query result to the table for Popup display.


Dim temptable as string = "<Table border = '0' cellpadding = '0' cellspacing = '1' style = 'background-color: # c0ffff; width: 100%; '>"
'Number of cyclic rows
While dr. Read ()
'Number of cyclic Columns


For I as integer = 0 to dr. fieldcount-1
Dim value as string


If system. Convert. isdbnull (dr. getvalue (I) then

value = "null"
else
'retrieve the value of this column.
value = dr. getvalue (I). tostring

end if
temptable = temptable + " "
' name of the Column Retrieved
temptable = temptable +" "+ dr. getname (I ). tostring () + ""
temptable = temptable + "" + value + ""
temptable = temptable + ""
next

End while
Dr. Close ()
Conn. Close ()


Temptable + = "<Table>"

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.