2009年9月21日 星期一

撈資料庫值顯示對照圖至表格

Dim sqlstr As String
Dim dr As SqlClient.SqlDataReader
sqlstr = "SELECT TDM_NAME FROM TN_C_TYPE"
Dim cmd As New SqlClient.SqlCommand(sqlstr, SqlConnection1)
Dim row As HtmlTableRow
Dim cell_Photo As HtmlTableCell
Dim cell_Text As HtmlTableCell
SqlConnection1.Open()
dr = cmd.ExecuteReader
While dr.Read
row = New HtmlTableRow
For i As Integer = 0 To dr.FieldCount - 1
cell_Text = New HtmlTableCell
cell_Photo = New HtmlTableCell
cell_Text.InnerText = dr.Item(i)
//dr.Item(0) ..資料庫第一欄 dr.Item(1) ..資料庫第二欄 cell_Photo.InnerHtml = " < img src='/PIC/Cutter_Pic/" & dr.Item(i) & ".jpg' align='center' onerror=this.style.display='none' src=''>" row.Cells.Add(cell_Text) row.Cells.Add(cell_Photo) Next Table1.Rows.Add(row) End While dr.Close() SqlConnection1.Close()

沒有留言:

張貼留言