开发者

ASP.NET Oracle Query

开发者 https://www.devze.com 2022-12-14 21:34 出处:网络
What code would put the results of the query (or any query) into an HTML t开发者_JS百科able? ReadOnly QUERY As String = \"SELECT * FROM DUAL\"

What code would put the results of the query (or any query) into an HTML t开发者_JS百科able?

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


First... add a table to your markup using <asp:Table id="myTable" runat="server"></asp:Table>

Then in your code, try this:

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


Loop over the reader using the boolean Read method:

while (myReader.Read())
{
    'Write out to html, or populate server side controls.
    'use myReader.GetXxx(index) methods here to get to the data
}
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号