Advertisement
Advertisement
| 07.23.2008 at 02:55PM PDT, ID: 23590342 |
|
[x]
Attachment Details
|
||
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: 48: 49: 50: 51: 52: 53: 54: 55: 56: 57: 58: 59: 60: 61: 62: 63: 64: 65: 66: 67: 68: 69: 70: 71: 72: 73: 74: 75: 76: 77: 78: 79: 80: 81: 82: 83: 84: 85: 86: 87: 88: 89: 90: 91: 92: 93: 94: 95: 96: 97: 98: 99: 100: 101: 102: 103: 104: 105: 106: 107: 108: 109: 110: 111: 112: 113: 114: 115: 116: 117: 118: 119: 120: 121: 122: 123: 124: 125: 126: 127: 128: 129: 130: 131: 132: 133: 134: |
Private Sub Race()
q3 = "3. Race:"
Dim Myconn As SqlConnection
Dim Mycomm As SqlCommand
Dim sql As String
Dim dtr As SqlDataReader
Myconn = New SqlConnection(ConfigurationSettings.AppSettings("gDataSource"))
Myconn.Open()
sql = "SELECT DISTINCT Count(race) AS RaceCount, race FROM tbl_Alumni_Survey_data GROUP BY race"
vHtml = vHtml & "<table cellpadding=""3"" cellspacing=""1"" width=""100%"" align=""center"">"
vHtml = vHtml & "<tr bgcolor=""#8B96B1"">"
vHtml = vHtml & "<th colspan=""11"" valign=""bottom"" align=""left"">"
vHtml = vHtml & "<FONT face=""Verdana"" size=""2"" align=""center"">" & q3 & "</FONT>"
vHtml = vHtml & "</th>"
vHtml = vHtml & "</tr>"
vHtml &= "<tr bgcolor=""E5E5E5"">"
Mycomm = New SqlCommand(sql, Myconn)
dtr = Mycomm.ExecuteReader()
Dim race As New ArrayList, RaceCount As New ArrayList
Dim totalCount = 0, tempCount As Integer
If dtr.HasRows Then
While dtr.Read()
race.Add(dtr("race")) 'Add new state to the list'
tempCount = CInt(dtr("RaceCount")) 'Convert to an integer'
RaceCount.Add(tempCount) 'Add new count to the list'
totalCount += tempCount 'Add count to the total'
End While
'display the statistics'
Dim done As Boolean = False
Dim rowCount = 0, i = 0, j As Integer = 0
Do
vHtml = vHtml & "<TD align=""left""><FONT face=""Verdana"" size=""1""></FONT></TD>"
While Int(i / 8) = rowCount And i < RaceCount.Count
If race(i) = "" Then
vHtml &= "<TD align=""left""><FONT face=""Verdana"" width=""11%"" size=""1"">Omit</FONT></>"
Else
vHtml &= "<TD align=""left""><FONT face=""Verdana"" width=""11%"" size=""1"">" & race(i) & " </FONT></TD>"
End If
i += 1
End While
vHtml &= "</TR><TR bgcolor=""#B9C0D0"">"
vHtml &= "<TD align=""left"" width=""11%""><FONT face=""Verdana"" size=""1""></FONT></TD>"
While Int(j / 8) = rowCount And j < RaceCount.Count
vHtml &= "<TD align=""left"" width=""11%""><FONT face=""Verdana"" size=""1"" align=""center""> " & CInt(RaceCount(j) / totalCount * 100) & "% </FONT></TD>"
vHtml &= "</th>"
j += 1
End While
vHtml &= "</TR><TR>"
rowCount += 1
If j = RaceCount.Count Then done = True 'Check if we are done'
Loop While done = False
End If
vHtml = vHtml & "</tr>"
vHtml = vHtml & "<tr bgcolor=""#E5E5E5"">"
vHtml = vHtml & "<td colspan=""11"" valign=""bottom"" align=""left"">"
vHtml = vHtml & " </td>"
vHtml = vHtml & "</tr>"
vHtml = vHtml & "<tr bgcolor=""#8B96B1"">"
vHtml = vHtml & "<td colspan=""11"" valign=""bottom"" align=""left"">"
vHtml = vHtml & " </td>"
vHtml = vHtml & "</tr>"
vHtml = vHtml & "</table>"
vHtml = vHtml & "<br/>"
End Sub
Private Sub CountState2()
Dim q4
q4 = "4. State of Current Residence:"
Dim Myconn As SqlConnection
Dim Mycomm As SqlCommand
Dim sql As String
Dim dtr As SqlDataReader
Myconn = New SqlConnection(ConfigurationSettings.AppSettings("gDataSource"))
Myconn.Open()
sql = "SELECT DISTINCT Count(state) AS StateCount, state FROM tbl_Alumni_Survey_data GROUP BY state"
vHtml = vHtml & "<table cellpadding=""3"" cellspacing=""1"" width=""100%"" align=""center"">"
vHtml = vHtml & "<tr bgcolor=""#8B96B1"">"
vHtml = vHtml & "<th colspan=""11"" valign=""bottom"" align=""left"">"
vHtml = vHtml & "<FONT face=""Verdana"" size=""2"" align=""center"">" & q4 & "</FONT>"
vHtml = vHtml & "</th>"
vHtml = vHtml & "</tr>"
vHtml &= "<tr bgcolor=""E5E5E5"">"
Mycomm = New SqlCommand(sql, Myconn)
dtr = Mycomm.ExecuteReader()
Dim states As New ArrayList, stateCounts As New ArrayList
Dim totalCount = 0, tempCount As Integer
If dtr.HasRows Then
While dtr.Read()
states.Add(dtr("state")) 'Add new state to the list'
tempCount = CInt(dtr("StateCount")) 'Convert to an integer'
stateCounts.Add(tempCount) 'Add new count to the list'
totalCount += tempCount 'Add count to the total'
End While
'display the statistics'
Dim done As Boolean = False
Dim rowCount = 0, i = 0, j As Integer = 0
Do
vHtml = vHtml & "<TD align=""left""><FONT face=""Verdana"" size=""1""></FONT></TD>"
While Int(i / 8) = rowCount And i < states.Count
If states(i) = "" Then
vHtml &= "<TD align=""left""><FONT face=""Verdana"" width=""11%"" size=""1"">Omit</FONT></>"
Else
vHtml &= "<TD align=""left""><FONT face=""Verdana"" width=""11%"" size=""1"">" & states(i) & " </FONT></TD>"
End If
i += 1
End While
vHtml &= "</TR><TR bgcolor=""#B9C0D0"">"
vHtml &= "<TD align=""left"" width=""11%""><FONT face=""Verdana"" size=""1""></FONT></TD>"
'While Int((j + 1) / 8) = rowCount And j < stateCounts.Count
While Int(j / 8) = rowCount And j < stateCounts.Count
vHtml &= "<TD align=""left"" width=""11%""><FONT face=""Verdana"" size=""1"" align=""center""> " & CInt(stateCounts(j) / totalCount * 100) & "% </FONT></TD>"
vHtml &= "</th>"
j += 1
End While
vHtml &= "</TR><TR>"
rowCount += 1
If j = stateCounts.Count Then done = True 'Check if we are done'
Loop While done = False
End If
vHtml = vHtml & "</tr>"
vHtml = vHtml & "<tr bgcolor=""#E5E5E5"">"
vHtml = vHtml & "<td colspan=""11"" valign=""bottom"" align=""left"">"
vHtml = vHtml & " </td>"
vHtml = vHtml & "</tr>"
vHtml = vHtml & "<tr bgcolor=""#8B96B1"">"
vHtml = vHtml & "<td colspan=""11"" valign=""bottom"" align=""left"">"
vHtml = vHtml & " </td>"
vHtml = vHtml & "</tr>"
vHtml = vHtml & "</table>"
vHtml = vHtml & "<br/>"
lblResults.Text = vHtml
End Sub
|