2014-03-07 30 views
0

基本上我有一個運行從應用程序快速SQL查詢並顯示錶(代碼如下所示)一個.asp頁:如何設置Oracle SQL輸出表的樣式?

<% 
Set DBConn = Server.CreateObject("ADODB.Connection") 
DBConn.Open "Driver={Oracle in OraClient11g_home1};DBQ=ORCL;UID=ops$USERNAME;PWD=PWD;" 
Set QueryResult = DBConn.Execute("SELECT * FROM LOAN") 
Response.Write "<table border=1 cellpadding=4>" 
Response.Write "<tr>" 
For I = 0 to QueryResult.Fields.Count - 1 
    Response.Write "<td><b>" & QueryResult(I).Name & "</b></td>" 
Next 
Response.Write "</tr>" 
Do While Not QueryResult.EOF 
    Response.Write "<tr>" 
    For I = 0 To QueryResult.Fields.Count - 1 
     Response.Write "<td>" & QueryResult(I) & "</td>" 
    Next 
    Response.Write "</tr>" 
    QueryResult.MoveNext 
Loop 
Response.Write "</table>" 

QueryResult.Close 
DBConn.Close 

%> 

我遇到的唯一問題是如何樣式表。我從來沒有做過這種輸出,我不知道我應該把樣式規則放在哪裏。我只需要它與網站其他部分的樣式相同:sans-serif等。另一件事是如何更改顯示列的標題?

感謝您的幫助,我很堅持了這個,因爲我從來沒有使用VBScript /的Oracle Application Express

回答

0

好工作,我會在標準的HTML標記封裝它使用標準的CSS樣式的輸出,是這樣的:

Response.Write "<html>" 
Response.Write "<head>" 
Response.Write "<style media="screen" type="text/css">" 
.. Add style rules here 
Response.Write "</style>" 
Response.Write "</head>" 
Response.Write "<body>" 
... Your table here 
Response.Write "</body>" 
Response.Write "</html>" 

然後爲你的表頭,這又是標準的HTML:

的Response.Write 「」

Response.Write "<thead>" 
Response.Write "<tr>" 
Response.Write "<th>1st column name</th>" 
Response.Write "<th>2nd column name</th>" 
... 
Response.Write "</thead>" 
Response.Write "<tbody>" 
Response.Write "<tr>" 
For I = 0 to QueryResult.Fields.Count - 1 
... your code 
Loop 
Response.Write "</tbody>" 
Response.Write "</table>" 

請小心避免HTML屬性的引號(media="screen")。