只是簡單的幾個code,就耗費了我半天的時間。
asp.net真的讓我用的很不習慣(不禁再三無言)
web developer他唯一的好處大概就在於有「編譯」的功能吧!但是他的html設計我真的一點都不喜歡

這次第一次的進度,大概完成了90%
重點就是
1.將特定資料表的各個欄位數值從資料表中讀取出來
2.將數值換算成百分比做統計
3.將百分比依照比率製成圖片
大概就這樣

因為根本不能用到girdview那種套件工具,所以就用了SqlDataReader,我根本不會asp.net,所以找這個東西加上try & error就耗去我好多時間
然後接著換成百分比的時候小數點太多了
開始找怎麼弄成剩下兩位數,網路上的答案好多,繼續嘗試try & error

其實東西感覺真的沒有很難
但是也可以耗掉我半天的時間...
把code放上來 做個紀錄!!!
真是寫不完的程式啊 (嘆)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
Dim mood(8) As Double
 
        Dim myCommand As SqlCommand
        Dim dr As SqlDataReader
        Dim myConnection As New SqlConnection("server=localhost;uid=sa;pwd=;database=hh")
 
        myConnection.Open()
        myCommand = New SqlCommand("select * from mood where mid=1", myConnection)
 
        dr = myCommand.ExecuteReader()
        While dr.Read()
            mood(0) = dr(1)
            mood(1) = dr(2)
            mood(2) = dr(3)
            mood(3) = dr(4)
            mood(4) = dr(5)
            mood(5) = dr(6)
            mood(6) = dr(7)
            mood(7) = dr(8)
            mood(8) = dr(9)
        End While
        dr.Close()
        myConnection.Close()
        Dim ave As Double
        ave = Val(mood(0)) + Val(mood(1)) + Val(mood(3)) + Val(mood(4)) + Val(mood(5)) + Val(mood(6)) + Val(mood(7)) + Val(mood(8))
 
        Dim result(8) As Double
        For i As Integer = 0 To 8
            result(i) = mood(i) / ave
        Next i
 
        Label0.Text = result(0).ToString("0.00")
        Label1.Text = result(1).ToString("0.00")
        Label2.Text = result(2).ToString("0.00")
        Label3.Text = result(3).ToString("0.00")
        Label4.Text = result(4).ToString("0.00")
        Label5.Text = result(5).ToString("0.00")
        Label6.Text = result(6).ToString("0.00")
        Label7.Text = result(7).ToString("0.00")
        Label8.Text = result(8).ToString("0.00")
 
        If Label0.Text > 0 Then
            Image0.ImageUrl = ("http://s760502.randombeauty.net/mu.png")
        End If
 
 
    End Sub

接著要找怎麼在html裡頭接收asp.net的值
拿php來說,wp這個網誌裡頭有

1
<?php bloginfo('template_url'); ?>

可以直接抓template的位置,應用在html裡頭
asp.net不知道要怎麼用
這邊有找到一個最貼切我需求的教學,但是我還是做不出來ˊˋ
ps.日落趕快來幫我:P