如何在文本框中显示总和? [英] How to display the total sum in textbox?
本文介绍了如何在文本框中显示总和?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我刚刚在 vb.net 示例中搜索了有关如何获取数据库总和"的示例,现在我得到了这个,但是如何在 textbox1 和 textbox2 中显示它?
I've just searched through vb.net examples on how to get the "SUM of a database", now I got this but how would I display this in textbox1 and textbox2?
但我不知道如何将其插入文本框.
But I don't know how to insert this to textbox.
Try
conn = New OleDbConnection(Get_Constring)
conn.Open()
cmd.Connection = conn
cmd.CommandType = CommandType.Text
sSQL=" Select userName,sum(quiz) as SumQuiz,sum(total) as Total From xxx where [username]='ad' And studentID='1111111'"
cmd.CommandText = sSQL
da.SelectCommand = cmd
推荐答案
我的 VB 没有那么强.您可以尝试使用 OleDbDataReader
将数据读入变量.然后将变量的值赋给 textbox1.Text
和 textbox2.Text
My VB is not that strong. You can try out OleDbDataReader
for reading the data into variables. Then assign the value of the variable to textbox1.Text
and textbox2.Text
Dim user As String
Dim sumQuiz As Integer
Dim total As Integer
Try
conn = New OleDbConnection(Get_Constring)
conn.Open()
cmd.Connection = conn
cmd.CommandType = CommandType.Text
sSQL=" Select userName,sum(quiz) as SumQuiz,sum(total) as Total From xxx where [username]='ad' And studentID='1111111'"
cmd.CommandText = sSQL
OleDbDataReader dr = cmd.ExecuteReader()
If dr.Read() Then
set user = Convert.ToString(dr["userName"])
set sumQuiz = Convert.ToInt32(dr["SumQuiz"])
set total = Convert.ToInt32(dr["Total"])
End If
这篇关于如何在文本框中显示总和?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文