Dim elem As String
elem = "College"
Dim conn As New SqlClient.SqlConnection
With conn
.ConnectionString = ("SERVER=ANINGDZTS-PC;DATABASE=AEVS_2013;Trusted_Connection = yes;")
.Open()
End With
Dim cmd As New SqlClient.SqlCommand
With cmd
.CommandText = "SELECT [PositionID],[Position],[Partylist],[Department],[Fullname],[Lvl],[Section],[Votes] FROM tbl_Cand WHERE [Department] = '" & elem & "'"
.CommandType = CommandType.Text
.CommandTimeout = 30
.Connection = conn
End With
Dim dt As New DataTable
dt.Load(cmd.ExecuteReader)
With DataGridView1
.AutoGenerateColumns = True
.DataSource = dt
End With
vvv()
cmd.Dispose()
cmd = Nothing
conn.Dispose()
conn = Nothing
这是我查看所有候选人的代码,但我只想获得累积票数最高的人的姓名和票数。例如,在总统中,我有 2 个候选人,但我只想查看谁的累积票数最高。