어떤 코드가 쿼리 (또는 쿼리)의 결과를 HTML 테이블에 넣을 수 있습니까?ASP.NET Oracle 쿼리
while (myReader.Read())
{
'Write out to html, or populate server side controls.
'use myReader.GetXxx(index) methods here to get to the data
}
어떤 코드가 쿼리 (또는 쿼리)의 결과를 HTML 테이블에 넣을 수 있습니까?ASP.NET Oracle 쿼리
while (myReader.Read())
{
'Write out to html, or populate server side controls.
'use myReader.GetXxx(index) methods here to get to the data
}
먼저 ... 코드에서 다음 <asp:Table id="myTable" runat="server"></asp:Table>
는,이 시도 사용하여 마크 업에 테이블을 추가 : 부울 Read 방법을 사용하여 지문 인식
ReadOnly QUERY As String = "SELECT * FROM DUAL"
Public Sub page_load()
Dim myConn As New OracleConnection(_
ConfigurationManager.ConnectionStrings("DB").ConnectionString)
myConn.Open()
Dim myCommand As New OracleCommand(QUERY, myConn)
Dim myReader As OracleDataReader
myReader = myCommand.ExecuteReader()
'Insert Code Here'
myConn.Close()
End Sub
특정 기능이 필요하지 않으면 OracleDataReader 개체 대신 IDataReader를 사용하는 것이 좋습니다. 이렇게하면 코드를 좀 더 일반적이고 이식성있게 만들 수 있습니다. –
루프
While myReader.Read
Dim myRow as HTMLTableRow = New HTMLTableRow
For i as Integer = 0 to myReader.FieldCount- 1
Dim myCell as HTMLTableCell = New HTMLTableCell
myCell.InnterText = myReader.GetString(i)
myRow.Cells.Add(myCell)
Next i
myTable.Rows.Add(myRow)
End While
'DUAL'에는 아무 것도 없으며'SELECT *'는 어떤 열도 반환하지 않습니다 –
@OMG 조랑말 : 그것은 절대적으로 사실이 아닙니다. DUAL에는 하나의 열 (DUMMY)과 하나의 행이 있습니다. – DCookie