伙计们如何将总和从数据库显示到 textbox1 和 textbox2?
Private Sub totalquiz()
Dim conn As New OleDbConnection
Dim cmd As New OleDbCommand
Dim da As New OleDbDataAdapter
Dim dt As New DataTable
Dim sSQL As String = String.Empty
Try
conn = New OleDbConnection(Get_Constring)
conn.Open()
sSQL = "Select sum(quiz) as score,sum(total) as total FROM prelimquiz where [username]='ad' And studentID='1111111'"
cmd.CommandText = sSQL
da.SelectCommand = cmd
da.Fill(dt)
textbox1.Text =dt.Rows[2].ToString()
textbox2.text =dt.rows[3].ToString()
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try
End Sub
我不知道如何正确获取总和并显示到文本框。