【问题标题】:How to display the total sum in textbox?如何在文本框中显示总和?
【发布时间】:2013-10-06 08:03:50
【问题描述】:

我刚刚在 vb.net 中搜索了有关如何获取“数据库的总和”的示例,现在我知道了,但是如何在 textbox1 和 textbox2 中显示它?

但我不知道如何将其插入文本框。

 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.net


    【解决方案1】:

    我的VB没那么强。您可以尝试OleDbDataReader 将数据读入变量。然后将变量的值赋给textbox1.Texttextbox2.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
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-06-18
      • 2021-02-28
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多