2014-05-13 44 views
1

我的工作會從數據庫中顯示數據的代碼替換HTA單元中的數據:如何使用VBScript

Set MyConn = CreateObject("ADODB.Connection") 
     MyConn.Open "Driver={Microsoft Visual FoxPro Driver};SourceType=DBF;SourceDB="&Datei&";Exclusive=No" 
     SQL_query1 = "SELECT DOW(daaprotx.datum)As Wochentag, Count(daaprotx.datum)/COUNT(DISTINCT daaprotx.datum)As Rückgaben FROM daaprotx WHERE BETWEEN (daaprotx.datum, gomonth(date(), -12), daaprotx.datum) AND(daaprotx.prottyp='1') AND(daaprotx.station='"&Station.options(Station.selectedIndex).value&"')Group by 1" 

    Set rs=CreateObject("ADODB.recordset") 
     rs.Open SQL_query1, MyConn 
     If Err.Number <>0 Then 
     MsgBox "Sie haben kein Verzeichnis ausgewählt" 
     End If 
     On Error Goto 0 
     str1 ="<table border=1 cellpadding=5 sortable><tr>" 
    For Each field In rs.Fields 
    str1 = str1 & "<th>" & field.Name & "</th>" 
    Next 
    str1 = str1 & "</tr>" 
    Do Until RS.EOF 
    str1 = str1 & "<tr>" 
    For Each field In rs.Fields 
    str1 = str1 & "<td>" & Round((field.Value),2) & "</td>" 

    Next 
    str1 = str1 & "<tr>" 
    rs.MoveNext 

    Loop 
    str1 = str1 & "</table>" 

    MainDisplay.InnerHTML = str1 


     rs.Close 
     Set rs = Nothing 
     MyConn.close 
     Set MyConn = Nothing 

的結果,我得到一個表如下:

wochentagrückgaben

2 107,69

3 114,97

5 93,06

6 88,35

所以,我想改變細胞1,1/2,1/3,1數..等在週一,週二等等。

我喜歡這樣的事情:in case of str1=2, replace str1 = monday,但我到現在還沒有找到方法。

回答

0

要得到工作日的名稱(字符串),請使用CDOW而不是DOW

(在長期範圍內,你應該做一些研究WRT顯示在HTML的記錄;你目前的做法是可怕的。)

+0

我與CDOW的問題是,再由集團通過名單將由年初sortet信件:星期五然後首先等等。我需要這個德國人的名字,所以我希望能取代最好的方式。這就是我選擇這種方式的原因。孔程序要大得多,但我已經寫了相關的代碼。 – Crying

+0

@Crying - 所以使用類似「SELECT CDOW()... ORDER BY DOW()」 –